javascriptandroidcordovaw3c-geolocation

navigator.geolocation.getCurrentPosition in cordova gives only 10 meter accuracy


navigator.geolocation.getCurrentPosition in cordova/android gives max 10 meter accuracy. I didn't use any plugin for geolocation. But some other apps shows 3 meter accuracy for the same place.

navigator.geolocation.getCurrentPosition won't give better accuracy?


Solution

  • Sadly the cordova-plugin-geolocation for Android doesn't provide any native code, just have the minimal code to handle the permissions for Android 6+. For getting the location it uses the WebView implementation of geolocation, so if using enableHighAccuracy: true you don't get the accuracy you expect, there is nothing you can do about it (maybe complain to Google so they improve it in future System WebView updates) The results will probably vary from vendors/Android versions.

    So if you need better accuracy you should search for a different plugin that uses native code for getting the location instead of using the one that the WebView provides. There are a few of them, better search for "background geolocation", as the ones providing background geolocation use native code.