Marco Cuccagna Marco Cuccagna - 6 months ago 19
Android Question

Phonegap geolocalization plugin

i'm developing through phonegap, i add the geolocalization plugin and it's working, the problem is if i run the application through phongapp desktop the localization works, but if i compile and generate the apk the localization doesn't works. Here is the js code:

function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}

// onSuccess Geolocation
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'Altitude: ' + position.coords.altitude + '<br />' +
'Accuracy: ' + position.coords.accuracy + '<br />';
}

Answer

confirm!

check the permission on platform/android/androidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />