i added Geolocation plugin in my app and used this code for getting the current location in phonegap. but this code does not work.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("4");
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
alert("1");
}
function onError(error) {
alert("3");
}
Where is the problem in my code?
thank you and sorry for my poor english.
check if geolocation is properly installed or not
restart your phone (silly solution but it works sometimes.I faced it once)
check if your geo permissions & settings are turned on in device
test with this code
options = { enableHighAccuracy: true };
navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
If you're using android, try to get the error with eclipse logcat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With