navigator.geolocation.getCurrentPosition in cordova gives only 10 meter accuracy
Asked Answered
B

1

7

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?

Bacchae answered 22/2, 2018 at 10:44 Comment(12)
in which platform? are you using enableHighAccuracy: true?Frayne
@Frayne Yes, i am using.Bacchae
And in which platform?Frayne
@Frayne android.Bacchae
@HabeebPerwad I linked your question to mine, having the same issue #49348989Trimetric
@Mirko Here is my understanding. Earlier there were no support for geolocation from the browser component in android. So the plugin had a native android location code to get the location. Once the browser component started providing gelocation, they dropped the Android Geolocation Code. Look like the browser geolocation code is giving maximum 10m accuracy irrespective of GPS availability or the device have better last know location data.Bacchae
@Mirko I took old tag 0.3.6 and modified for my purpose.Bacchae
@HabeebPerwad we have always used the geolocation plugin 2.2.0 and we used to have no issues at all (4/6 meters accuracy), now it is suddenly capped at 10mTrimetric
@Mirko No idea what happened to it. I couldn't find any reference mentioning that it will be capped to 10m in geolocation.Bacchae
Are there any major issues with pre 0.3.6 versions?Cumin
@Cumin No idea bro.Bacchae
I answered a similar question here #49348989Trimetric
F
4

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.

Frayne answered 26/2, 2018 at 11:22 Comment(8)
There is any reference stating that webview will give only max 10 meter accuracy?Bacchae
They had native code till tag 0.3.6Bacchae
No, there is no information about the internals of the WebView geolocation implementation or accuracy, as I say, it might vary on different devices or vendors. The 0.3.6 version of the plugin is very old, the native code is really out of date, it won't be able to handle the Android 6+ permissions, so better look for an alternative.Frayne
I used to get up to 4 meters, now I get 10 meters max as well, after upgrading to Oreo.Trimetric
We used to get down to 4 meters on our app, now we had lots of users complaining about the accuracy not going below 10 meters. We are baffled, as we did not change anything on our app.Trimetric
@Frayne Also, someone is facing the same problem with native code, see #49045231Trimetric
@Frayne I added my own question here #49348989Trimetric
For those interested, I reported this to the Chrome team which opened an issue to trace this: bugs.chromium.org/p/chromium/issues/…Obrien

© 2022 - 2024 — McMap. All rights reserved.