Я использую cordova-2.0.0 и Android-эмулятор google api level16.
Всякий раз, когда я запускаю navigator.geolocation.getCurrentPosition
, я всегда получаю error3
.
мой код короткий:
// 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");
}
Если у кого есть идея, почему возникает error3
, просьба дать предложения. Большое спасибо