OGeek|极客世界-中国程序员成长平台

标题: android - PhoneGap 3.3 : how to have the best accuracy? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 21:48
标题: android - PhoneGap 3.3 : how to have the best accuracy?

我使用 PhoneGap 制作了一个应用程序,我需要尽可能好的地理位置。

我用这个:

var options = { enableHighAccuracy: true, timeout:30000};
navigator.geolocation.getCurrentPosition(success, fail, options);

我尝试通过以下方式优化搜索:

var options = { enableHighAccuracy: true, timeout:30000};
navigator.geolocation.watchPosition(success, fail, options)

但它返回的准确度大致相同(在几种类型的地方在 10 到 40 之间)。

此外,地理定位功能(getCurrentPosition 和 watchPosition)非常慢。通常会超过超时时间(30 秒)。

我在网络上做了很多研究,但没有发现任何可以帮助我的东西。你可以帮帮我吗?有没有获得最佳地理位置的好方法?是否可以使用 PhoneGap,循环接收每秒一次的 gps 数据?

提前谢谢你。

问候。



Best Answer-推荐答案


好的,我找到了解决方案...

在文件 app/platforms/android/src/org/apache/cordova/geolocation/GPSListener.java 中:

我变了:

this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);

通过

this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this);

这样,我接收 GPS 数据的速度要快得多。我愿意

watchID = navigator.geolocation.watchPosition(geolocalizeWatchSuccess, geolocalizeWatchError, { timeout: 20000 , enableHighAccuracy: true, maximumAge: 30000});

而且我捕捉到了最好的准确性。

显然这个问题来自 phonegap 3.x。

再见。

关于android - PhoneGap 3.3 : how to have the best accuracy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23271189/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4