Is it possible to get maximal GPS precision on mobile browser?

本秂侑毒 提交于 2019-12-18 04:22:04

问题


Is it possible to receive GPS position with the maximal precision available on a mobile device from within the web browser?

I've made tests on mobile devices using both getCurrentPosition() and watchPosition() from HTML5 Geolocation, walking around an office building. I've received on Android HTC Desire (Android Browser) and iPhone 3 (Safari) maximal precision of 70m, and no altitude/speed data, with WiFi turned on. After the WiFi was turned off, accuracy fell to 800-1000 meters.

In the same time, on GPS Test app on Android, I've received GPS position accuracy of 14m, and additionally altitude and speed data.

So, as I see, I've not received in both devices in mobile browser either the full data set available on GPS, nor the precision possible for device sensors to reach.

So, my question is, is the GPS data set that browsers receive is limited by devices, or can the browser itself not make full use of it? I would like to have full GPS precision in my web application without need to write a 'normal' mobile app.


回答1:


As per this answer, you could try using the enableHighAccuracy option (if you’re not already).

But see Why is Geolocation in Mobile Safari way less accurate than the location in a native App? in relation to the iPhone, where it seems like the JavaScript geolocation API in Mobile Safari doesn’t get as accurate location information as the Location Services API for native apps.




回答2:


OK, my work-collegue gave me very valuable hint.

For security reasons, built-in browser for Android (so, Android browser, on which I've made tests) doesn't get GPS location with full precision. Precision is with premeditation lowered. So that, when WiFi was switched off, I've got response that accurance is 800-1000 meters. With WiFi turned on, the accurance I've received on callback was abount 70 meters.

So, I've made test with Opera Mobile and Firefox, which are requiring permission to get accurate location from GPS when installed (same as GPS test). These browsers, after switching GPS off received data with accurance < 10 meters, same as native app.

So the answer for Android is: do not use Android Browser for web sites, for which you want to get GPS location with high accuracy. It seems that Google people decided, that if user did not accepted GPS precise location for Android Browser, he may not be aware, that this browser gives so precise data to WWW sites. As for Opera and Firefox - it's user-installed app, so it's his choice.

The test for iPhone with WiFi switched off gave 50 meters precision for Safari. So the accuracy is much less restricted as for Android, however the restriction is made. However, there's a problem with replacing Safari with other HTML5-supporting browser, since Opera stopped its development for iPhone.

All tests were made outside of the office building, when 10-12 GPS transmitters where in sight.



来源:https://stackoverflow.com/questions/8257160/is-it-possible-to-get-maximal-gps-precision-on-mobile-browser

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