我使用cordova-2.0.0和
android模拟器google api level16.
每当我运行navigator.geolocation.getCurrentPosition我总是得到错误3.
我的代码简介如下:
// 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被提出,请提出建议.非常感谢