【发布时间】:2014-06-10 13:49:26
【问题描述】:
我正在尝试在我的 JQM / Phonegap 应用程序中加载 GPS 坐标 - 尝试命中的第一个警报,但其余的都失败了,我看不到任何错误。据我所知,没有达到 onsucess 或 onerror。
if (pageId === 'latlong') {
console.log("Nooooooops");
alert("trying");
navigator.geolocation.getCurrentPosition(onSuccess, onError);
function onSuccess(position) {
localStorage.set("Lat", position.coords.latitude);
localStorage.set("Long", position.coords.longitude);
alert(localStorage.getItem("Lat"));
alert(localStorage.getItem("Long"));
};
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
$("#latlongLat").append(localStorage.get("Lat"));
$("#latlongLong").append(localStorage.get("Long"));
}
我正在 AVD 和三星 Galaxy s4 上尝试这个,但没有运气。
【问题讨论】:
-
你安装了Phonegap地理定位插件吗?
标签: javascript android jquery jquery-mobile cordova