我使用的科尔多瓦-2.0.0和Android模拟器谷歌API level16。
I am using cordova-2.0.0 and android emulator google api level16.
每当我跑 navigator.geolocation.getCurrentPosition
我总是误差3
。
我的code简单是因为:
Whenever I run navigator.geolocation.getCurrentPosition
I always get error3
.
my code brief is as:
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
console.log("Entering index.html.onDeviceReady");
var networkState = navigator.network.connection.type;
getPosition(networkState);
}
function getPosition(networkState) {
console.log("Entering getPosition function");
console.log("networkState is: " + networkState);
if (networkState !== null) {
navigator.geolocation.getCurrentPosition(onSuccess, onError, {
maximumAge : Infinity,
timeout : 5000,
enableHighAccuracy : true
});
} else {
alert('Please check your network connection and try again.');
}
console.log("Leaving getPosition function");
}
// function for lat & lng
function onSuccess(position) {
console.log("Entering onSuccess(position) function");
console.log("Latitude is: " + position.coords.latitude);
console.log("longitude is: " + position.coords.longitude);
lat = position.coords.latitude;
lng = position.coords.longitude;
console.log("Leaving onSuccess(position) function");
}
// function for lat & lng
function onError(error) {
console.log("Entering onError(error) function");
alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
console.log("Leaving onError(error) function");
}
如果任何人有想法,为什么误差3
上升,请给点建议。非常感谢
If anyone have idea why error3
is raised, please give suggestions. Thanks a lot
我没设置
enableHighAccuracy: false
太多,但害怕错误code 3不停地弹出了... 无论
too, but dreading "error code 3" kept popping out... Neither
browser / settings / privacy and security / position / delete position access data
确实帮助... 只有功率循环(但我想浏览器杀会做同样的)安卓(4.1.2)没有强制浏览器重复问题份额第一的位置?给用户,抛出错误code 3出了门......
did help... Only power cycling (but I suppose a browser kill would do the same) Android (4.1.2) did force the browser to repeat the question "Share position?" to the user, throw error code 3 out of the door...
我想在某些情况下(即我不能重复,不好意思)浏览器存储为该网站一个无效的位置 - 或 - 记得共享拒绝该网站...
I suppose in some situation (that I can't repeat, sorry) the browser stores an invalid position for that site - or - remembers a sharing denial for that site...
对不起,我迟到应答(也许在一个不完整的方式)......如果有人有更有力的证据,请分享...: - )
Sorry for late answering (and perhaps in an incomplete way)... If somebody has better evidence please share it... :-)