2009-11-07 39 views
0

請任何人都可以幫助我獲取用戶的緯度/經度位置。我嘗試了很多東西,但我無法解決這個問題。如果有人有一個想法,請幫助我。無法在iPhone中使用lat和long獲取地址

我是iPhone的初學者,所以請簡單說明一下。

+0

如何在沒有iphone的情況下做到這一點?使用相同的方法。 – 2009-11-07 13:40:21

回答

1

我假設你的意思是在瀏覽器中(而不是本地應用程序),因爲你已經把這個問題標記爲javascript。你可以通過異步回調做到這一點:

//Function that does something once the device has a location 
//May be called repeatedly 
function handler(location) { 
    var longitude = location.coords.longitude; 
    var latitude = location.coords.latitude; 
    var accuracy = location.coords.accuracy 

    //Do something with them 
} 

//Register the handler and tell the phone to start finding a location 
navigator.geolocation.getCurrentPosition(handler); 

這是HTML5的地理位置東西所有部分,有一個草案here

相關問題