1
我正在嘗試使用地理位置進行一些操作。我想要返回一個變量的地理位置緯度和經度作爲數組。它不起作用。我認爲代碼中的第一行是問題。是否有可能得到這樣的價值(與回報)?Javascript地理位置
startingPoint = navigator.geolocation.getCurrentPosition(onGeoSuccess);
function onGeoSuccess(position) {
start['lat'] = position.coords.latitude;
start['lng'] = position.coords.longitude;
return start;
}
有沒有更好的解決方案?我不想在onGeoSuccess中執行其他代碼,我想返回值。
謝謝。我知道。但我的問題是,我可以在代碼中的第5行上做這樣的事情:mypos = navigator.geolocation.getCurrentPostion(showPosiiton); ? – FishWave