Blog Post

Improving PhoneGap geolocation for Android
Android, Mobile

Improving PhoneGap geolocation for Android 

Some Android devices have the problem of not being able to obtain the user’s current geolocation using the following standard code:

navigator.geolocation.getCurrentPosition(onSuccess, onError, options);

The first possible solution to this problem is to add the following options parameter:

options = { enableHighAccuracy: true,timeout: 5000,maximumAge: 0,desiredAccuracy: 0, frequency: 1 };

If that doesn’t work, the other possible solution is to stop using getCurrentPosition and start using the following:

var watchID = null;
if (navigator.geolocation) {
     watchID = navigator.geolocation.watchPosition(
     function showPosition(position{
     function showError(error) { },
     { enableHighAccuracy: true,timeout: 5000,maximumAge: 0,
        desiredAccuracy: 0, frequency: 1 }

(Visited 227 times, 1 visits today)

Related posts

Leave a Reply

Required fields are marked *