2011-11-23 65 views

回答

3

我剛剛在一個項目中使用了它,我使用Ben Nadel's blogpost和API本身來解決它。

navigator.geolocation.watchPosition(function(position){ 

    // These variables update every time the location changes 
    var Latitude = position.coords.latitude; 
    var Longitude = position.coords.longitude; 

}, function(error){ 
    // You can detect the reason and alert it; I chose not to. 
    alert('We could not get your location'); 
},{ 
    // It'll stop looking after an hour. Enabling high accuracy tells it to use GPS if it's available 
    timeout: 5000, 
    maximumAge: 600000, 
    enableHighAccuracy: true 
}); 

希望這會有所幫助!

相關問題