topical media & game development
mobile-application-11-DerbyApp.iPhone-www-gps.htm / htm
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
<script type="text/javascript" src="js\jquery.min.js"></script>
</head>
<body onload="onLoad()">
<a href="index.html">Back</a>
<div id="main" ontouchmove="touchMove(event);">
<div class="header"><div class="headertext">Derby Data</div>
</div>
<div id="GPSInfo" >
</div>
</div>
</body>
<script type="text/javascript" charset="utf-8">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(gpsSuccess, gpsFailure);
}
function gpsSuccess(location){
try{
var gpsinfo = '<ul><li>Latitude: ' + location.coords.latitude + '</li>';
gpsinfo += '<li>longitude: ' + location.coords.longitude + '</li>';
gpsinfo += '<li>Altitude: ' + location.coords.altitude + '</li>';
gpsinfo += '<li>Accuracy: ' + location.coords.accuracy + '</li>';
gpsinfo += '<li>Speed: ' + location.coords.speed + '</li></ul>';
jQuery('#GPSInfo').html(gpsinfo);
}
catch(err){
alert(err);
}
//alert(location.coords.latitude);
//alert(location.coords.longitude);
//alert(location.coords.altitude);
//alert(location.coords.accuracy);
//alert(location.coords.speed);
}
function gpsFailure(PositionError){
alert(PositionError.code);
alert(PositionError.message);
}
</script>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.