Why is Geolocation in Mobile Safari way less accurate than the location in a native App?

陌路散爱 提交于 2019-12-21 12:32:04

问题


I'm using the Geolocation API (often referred to as "HTML5 Geolocation") to get the current position of the user. It is updated automatically if you move (checked every second). Primarily targeted (and currently tested) at iPhones, but should work on other mobile devices too. You can see an example here:

http://jsbin.com/uyoyey/

The accuracy, which you can see in each line after the pipe, is around 3000 (meters) when I'm testing (outside). Which is quite bad obviously. The native Maps-App on my iPhone is way more precise. Approximately around 10 to 30 Meters (by looking at the map and where I am standing. Checking long- and lat-values in another app also gives more accurate numbers.

When I now switch back to Safari the accuracy jumps to 10 to 30 but reverts back to 3000 after a second.

Questions:

  1. Can you replicate this behavior?
  2. Why is the location so far off in the first place?
  3. Is there a difference between accessing GPS-Data via Geolocation and CLLocationManager (which I think is used by native apps)?

Thanks!

Update 1:
I'm getting more accurate results when testing on other places (larger city) but am now wondering if the native Apps also use Motion Tracking to update the location. Which would explain why the Maps App can track my steps while Safari doesn't recognize them.

Update 2 (03.08.11):
In an email-conversation with Peter-Paul Koch he wrote that Safari mainly uses wifi for Geolocation to preserve battery life. Which may explain the differences.
Im still not entirely sure what is going on though.


回答1:


Old: Here are the test result for getCurrentPosition function with wifi turned off on android 2.2, iOS4, and iOS5.

On both android browser and iOS 4 Safari, I'm getting GPS accuracy level in magnitude of 1000 meters. But on iOS 5 Safari, I'm able to get down to 5 meter accuracy. Seems GPS has improved on iOS 5, but it is just a small slice of the market out there. Overall, it is still not good to develop web app that relies on accurate GPS reading.

Something I found during testing - the android browser GPS stops responding after about 70 calls made to getCurrentLocation. This might be a device specific problem but it is another unreliable factor in browser based GPS functionality.

Update: I was testing with the watchPosition function call and it is produced much more accurate result on Android and iOS4. It the way to go... Sample code: http://jsbin.com/ugebif/3




回答2:


  1. I can’t, but only due to laziness :)

  2. I’m not sure, but I suspect Safari is using the non-GPS parts of the iPhone’s location awareness.

  3. Again, I’m not sure, but Dive into HTML5 mentions that the HTML5 geolocation API lets you pass a PositionOptions object to getCurrentPosition, and that this object has an enableHighAccuracy property.

    Setting that to true might make Safari use the same high-accuracy positioning as CLLocationManager. (I’ve no experience with this myself though.)



来源:https://stackoverflow.com/questions/6790368/why-is-geolocation-in-mobile-safari-way-less-accurate-than-the-location-in-a-nat

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