HTML5 geolocation watchPosition immer aufgerufen, nur einmal

Ich bin erstellen einer android-Anwendung mit html-5 und ich will den Zugang latlong vom Benutzer als der Benutzer bewegt. Ich habe verwendet, watchPostion aber es isgiving mich dem Standort der Benutzer nur einmal.

    var watchID;
var geoLoc;

function showLocation(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;

    var ll=new google.maps.LatLng(latitude, longitude);
    map.setCenter(ll);

  console.log("Latitude : " + latitude + " Longitude: " + longitude);
}

function errorHandler(err) {
  if(err.code == 1) {
    console.log("Error: Access is denied!");
  }else if( err.code == 2) {
    console.log("Error: Position is unavailable!");
  }
    }
    if(navigator.geolocation){
      //timeout at 60000 milliseconds (60 seconds)
      var options = {timeout:60000};
      geoLoc = navigator.geolocation;
      watchID = geoLoc.watchPosition(showLocation, 
                                     errorHandler,
                                     options);


   }else{
      console.log("Sorry, browser does not support geolocation!");
   }
InformationsquelleAutor Naeem Shaikh | 2014-05-16
Schreibe einen Kommentar