Cordova 3.3.0 ( aka.Phonegap) Android Geolocation is not accurate

I am working on Cordova 3.3.0 and Google Maps API, What i noticed is that Google maps are not accurate on my current location.

I tried using below line of code as per cordova documents :

        = {maximumAge : 3000 , timeout : 5000 ,enableHighAccuracy :true};

Now i get time out response from above code. So i changed my code to below

        var options =  { maximumAge: 500000, timeout: 6000, enableHighAccuracy: true };
        navigator.geolocation.getCurrentPosition(onSuccess , onError , options );

This above code helped me to fix timeout error, hoohooo.. great . I thought this is working fine. However after multiple test like while walking/Driving i noticed that location is not accurate, now that is a problem….

After long research i am able to figure it out.

What you have to do: Use the html5 only api for geolocation and do not include geolocation plugin provided by cordova.

If you already have it on in your project, Please remove it using below command.

		cordova plugin rm org.apache.cordova.geolocation

And make sure you still have below line of code in your Android Mainfest 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" />

Now build your app, you are good to go.

This worked for me, Let me know if you have any suggestions or comments or need any help.


2 thoughts on “Cordova 3.3.0 ( aka.Phonegap) Android Geolocation is not accurate

    1. The HTML Geolocation API is used to get the geographical position of a user.

      Since this can compromise privacy, the position is not available unless the user approves it.

      So question is did you approved it? something like Allow or Don’t allow popup?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s