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

元气小坏坏 提交于 2019-12-01 17:02:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/48925394/navigator-geolocation-getcurrentposition-in-cordova-gives-only-10-meter-accuracy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!