웹 페이지를 사용하여 GPS 위치 검색
코드 샘플: 웹 페이지를 사용하여 GPS 위치 검색
다음 코드 샘플에서는 웹 페이지가 BlackBerry Browser에 의해 로드되었는지, BlackBerry 단말기가 GPS 기능을 지원하는지 확인하는 방법을 보여줍니다. 이 조건들이 참인 경우, 웹 페이지는 위치 추적 시작을 위한 업데이트된 위치 정보를 받습니다.
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>GPS Testing</title>
</head>
<body>
<script type="text/javascript">
var modeCellsite = 0;
var modeAssisted = 1;
var modeAutonomous = 2;
function locationChanged()
{
alert("Lat " + blackberry.location.latitude +
" Lon " + blackberry.location.longitude +
" Time " + blackberry.location.timestamp );
return true;
}
if ( window.blackberry && blackberry.location.GPSSupported )
{
var isUpdated = false;
var theCount = 0;
alert("Location tracking is supported");
blackberry.location.onLocationUpdate("locationChanged()");
blackberry.location.setAidMode(modeAutonomous);
while ( theCount++ < 10 && !isUpdated )
isUpdated = blackberry.location.refreshLocation();
}
else
{
document.write("Location tracking is not supported");
}
</script>
</body>
</html>
다음 주제: 웹 페이지를 사용하여 GPS 위치 검색