我在我的应用程序中添加了Geolocation插件,并使用此代码获取phonegap中的当前位置.但是这段代码不起作用. document.addEventListener("deviceready", onDeviceReady, false);function onDeviceReady() { alert("4"); n
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("4");
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
alert("1");
}
function onError(error) {
alert("3");
}
我的代码中的问题在哪里?
谢谢你,对不起我的英语不好.
>检查地理定位是否正确安装>重新启动你的手机(愚蠢的解决方案,但它有时工作.我面对它一次)
>检查您的地理位置权限&设备已在设备中打开
>使用此代码进行测试
options = {enableHighAccuracy:true};navigator.geolocation.getCurrentPosition(onSuccess,onError,options);>如果您正在使用android,请尝试使用eclipse logcat获取错误.
