Phonegap Android and GPS satellite

人走茶凉 提交于 2019-12-05 17:51:30

问题


It seems phonegap does not use GPS satellite instead geolocation from cellular network. I am not satisfied with the accuracy, always between 150-1000 meters. GPS activity logo is not displayed as well.

Is there any way to force an android app to use GPS satellites even if other methods are available? Is there any way to override the default function to activate the GPS sat usage?

Thanks in advance


回答1:


PhoneGap actually uses GPS satellite geolocation just as Android platform does. You should be receiving locations with a more precise accuracy than 150m if your phone's GPS is enabled. Whenever you call the geolocation.getCurrentPosition() or geolocation.watchPosition() methods, PhoneGap's GeoListener class asks for a GPS provider and a NETWORK provider, then it creates a listener for both providers, if they exist. This is the reason you are getting a wide range of accuracies.

So in case you want to force high accuracy locations, you could set it to true on the geolocationOptions parameter passed to the above methods. Check the API: geolocationOptions

navigator.geolocation.watchPosition(
    onSuccess, onError, 
    { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });

In case you want to have more control and a more accurate behaviour of location requests you can extend PhoneGap's API to do so.



来源:https://stackoverflow.com/questions/7714347/phonegap-android-and-gps-satellite

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