1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
</head>
<body>
<p id="geolocation">Finding geolocation...</p>
</body>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);;
document.addEventListener("DomContentLoaded" function(){
alert("Hello LTM geolocalisation - touch please ");},false);
function onDeviceReady() {
alert("Device prêt");
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
/ onSuccess Geolocation
function onSuccess(position) {
alert( "onSuccess !" );
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '
' +
'Longitude: ' + position.coords.longitude + '
' +
'Altitude: ' + position.coords.altitude + '
' +
'Accuracy: ' + position.coords.accuracy + '
' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '
' +
'Heading: ' + position.coords.heading + '
' +
'Speed: ' + position.coords.speed + '
' +
'Timestamp: ' + new Date(position.timestamp) + '
';
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</html> |
Partager