我有一个问题,看起来非常直截了当,但我不明白我哪里出错了!PhoneGap - 地理位置错误
我使用的PhoneGap(2.9版本)来获得地理定位数据。在初始化时调用以下函数(getGeolocationData)。问题是与位置服务的条件...
如果定位服务是申请后,启动时,获得地理定位数据 。 (OK)
如果位置服务在应用程序启动时关闭,则会显示错误 并再次调用地理定位功能。 (OK)
如果申请后,启动时,获得位置服务地理定位数据,但在使用过程中,如果我停用定位服务时,不会出现错误! (错误)。
注意:当位置服务关闭时,不再调用警报消息'geoGeo called'。
谁能帮我这个恼人的问题?
在此先感谢!
瑞安
function getGeolocationData() {
alert("getGeo called.");
var options = { maximumAge: 7000, timeout: 7000, enableHighAccuracy: true };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
}
// onSuccess Geolocation
function onSuccess(position) {
lng = position.coords.longitude;
lat = position.coords.latitude;
acc = position.coords.accuracy;
alt = position.coords.altitude;
hdg = position.coords.heading;
spd = position.coords.speed;
geo_flag = 1; //obtained geolocation? 1 = Yes/0 = No
document.getElementById("geo-status").innerHTML = 'On';
alert("success");
}
// onError Callback receives a PositionError object
function onError(error) {
document.getElementById("tracking-status").innerHTML = 'Off';
document.getElementById("geo-status").innerHTML = 'Off';
geo_flag = 0; //obtained geolocation? 1 = Yes/0 = No
alert("failed");
getGeolocationData();
}
大家好,我刚刚更新到phoneGap 3.5.0,错误仍然存在!似乎不需要为此找到解决方法.... – EvilGenius82
我刚刚检查了几个网站,它似乎在phonegap的2.9版本中存在缺陷。我会尽快更新版本并在此发布结果。谢谢瑞恩 –