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 62 63 64 65 66 67 68
| <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<style type="text/css">
@font-face {
font-family: "arial";
src: url(arial.ttf) format("truetype");
}
</style>
<script type="text/javascript">
function startWatch(){
if (navigator.geolocation)
var watchId = navigator.geolocation.watchPosition(successCallback,
errorCallback,
{enableHighAccuracy:true,
timeout:10000,
maximumAge:0});
else
alert("Votre navigateur ne prend pas en compte la géolocalisation HTML5");
}
function stopWatch(){
navigator.geolocation.clearWatch(watchId);
}
function successCallback(position){
document.getElementById("lat").innerHTML = position.coords.latitude;
document.getElementById("long").innerHTML = position.coords.longitude;
document.getElementById("prec").innerHTML = position.coords.accuracy;
document.getElementById("alt").innerHTML = position.coords.altitude;
document.getElementById("precalt").innerHTML = position.coords.altitudeAccuracy;
document.getElementById("angle").innerHTML = position.coords.heading;
document.getElementById("speed").innerHTML = position.coords.speed;
document.getElementById("time").innerHTML = new Date(position.timestamp);
};
function errorCallback(error){
switch(error.code){
case error.PERMISSION_DENIED:
alert("L'utilisateur n'a pas autorisé l'accès à sa position");
break;
case error.POSITION_UNAVAILABLE:
alert("L'emplacement de l'utilisateur n'a pas pu être déterminé");
break;
case error.TIMEOUT:
alert("Le service n'a pas répondu à temps");
break;
}
};
</script>
</head>
<body>
<p><FONT face="arial" color="red"><span id="lat"></span></FONT>Latitude : </p>
<p><FONT face="arial" color="red"><span id="long"></span></FONT>Longitude : </p>
<p><FONT face="arial" color="red"><span id="prec"></span></FONT>Précision : </p>
<p><FONT face="arial" color="red"><span id="alt"></span></FONT>Altitude : </p>
<p><FONT face="arial" color="red"><span id="precalt"></span></FONT>Précision altitude : </p>
<body onload="startWatch();">
</body>
</html> |
Partager