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
| 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){
var x="Latitude=" + position.coords.latitude +
"&Longitude=" + position.coords.longitude;
document.getElementById("resto").href='rechresto.php?'+x;
document.getElementById("mos").href='rechmos.php?'+x;
};
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;
}
}; |
Partager