views:

864

answers:

5

Here's my situation; I've built a very simple web app that looks up a users location and plots it on a Google map. Here's my code: http://pastebin.com/d3a185efd

When I test it, my location is detected as being >= 500 meters from where I actually stand.

BUT

When I open up Google Maps or Gowalla my location is correct to within <20 meters?

So my question is: Do native iPhone apps benefit from a higher accuracy rate than web apps?

If so, why?

A: 

I think that a webapp relies on a geoip service that (does its best to...) converts your IP address into a GPS coordinate. ex: service ex

However such way to retrieve a coordinate cannot be as accurate as the "classic" one that uses a GPS device (such as the one included in the 3G or 3Gs iphone) to really retrieve your actual location and not approximate it at its best like a geoip service.

UPDATE: GEOIP is used when using google maps on a laptop for instance, but maybe your question was : "when I use the HTML 5 position object in my web page, does it comes from the GPS hardware or from a geoip service ?". This I couldn't really tell, I would say it uses geoip service instead of GPS hardware but I'm not 100% sure...

yonel
That wasn't really my question as I'm sure the HTML 5 geolocation api checks whether your device is GPS capable and falls back to GeoIP if not. So my question still remains, do native iPhone apps use the same methodology (or one of equal accuracy) to web apps or are they superior in some way?
Sam
I think this relies on the implementation of the browser : let's suppose mobile safari checks the last retrieved location from the GPS hardware and returns it to the web page on demand, I don't see why there would be such a difference between webapps and native apps : the flow between webapp / objC would end up asking the same location.
yonel
That's what I thought, but if that's the case - why is there such a big difference in accuracy?
Sam
A: 

The code doesn't show where you get position from - are you using Navigator and Geolocation objects?

http://developer.apple.com/iphone/library/documentation/AppleApplications/Reference/SafariWebContent/GettingGeographicalLocations/GettingGeographicalLocations.html

Kendall Helmstetter Gelner
Yes, my web app uses `navigator.geolocation.watchPosition()` for the iPhone and Android phones and `navigator.geolocation.getCurrentPosition()` for all others. I'm not sure what Google maps uses, but as it's web-based I'd imagine it uses the same JS.
Sam
+1  A: 

Based on the following link, I believe you are getting coordinates in web app through tower triangulation and not using GPS. I really doubt if GeoIP can give coordinates within 500 meters.

http://phonegap.lighthouseapp.com/projects/20116/tickets/16-navigatorgeolocation-does-not-make-use-of-gps-data

rohit
+1  A: 

According to the specification, webapp geolocation should use whatever positioning method works best in any situation - so in theory, one would assume it uses GPS when available. The discussion linked in the "best answer" by rohit doesn't seem conclusive to me - here is another one, with someone reporting a similar problem to yours and other users professing to getting accurate gps data (scroll down to comments 26-28 Sept):

http://www.thecssninja.com/javascript/geolocation-iphone

But it does seem like the geolocation stuff is buggy still. I'd suspect your problem is basically that, some bug.

Anders Sundnes Løvlie
A: 

for google geo api first it tries to find your location by device gps , if failed it goes cell triangulation (virtual gps) if failed it try to use to wifi mac and ip addresses , the last try is to use the client IP to get his location

Galaxy