How does HTML5 Geolocation Work?
Asked Answered
P

5

75

Chrome and Firefox have HTML Geolocation implemented.

My question is: how does it work? Do they have a Database locally and get the information from the provider then try to match it?

Where is the DB stored ? Can it be accessed ?

Update1: the only downside to geolocation is the browser has to ask the user for permission and this is really a bad thing for usability. I understand the security issue but still I don't see how this will become a popular solution.

Update2 : Firefox is using a Google WebService to detect the location. Now this seems very strange considering they are competitors now. Also this behavior it's really unexpected for me... I hopped each browser will have it's on (maybe offline) solution.

Update3 : So the browsers actually sniff for routers using your wireless network card?

Update4 : In the end what informations is the browser sending to the the google webservice ? The detected SSID seems ok ( and it makes sense that if they are tracked by google based on their physical position to make a lookup in the database for matching informations ) but how does it work so well in country where google didn't scanned this ? The other info your browser is sending is your ip but this is not enough to pin point your exact location right ?

Regarding other browsers that might implement this. How should they do it ? The api is not documented only the old deprecated GEAR api gives some clue. So this is not really public.

Pestalozzi answered 18/11, 2010 at 9:40 Comment(3)
I suspect, based on mozilla.com/en-GB/firefox/geolocation, that if you're on a desktop it just does an IP location lookup using Google Location ServicesLegionary
Doesn't answer your question, but here's an amazing demo (try it in Chrome): html5demos.com/geoHandoff
possible duplicate of How, exactly does HTML5's GeoLocation work?Antecedent
Z
24

For what it's worth, the API specification itself is agnostic to the geolocation implementation. So while it's true that Mozilla Firefox and Google Chrome both rely on network-enabled geolocation via Google's Location Service database, that's not a requirement of the standard. For example, Mobile Safari on your iPhone will in some cases use GPS rather than WiFi-triangulation or cell-site geolocation, depending on what location service is most accurate and accessible at a given moment.

And we can hope that future browsers will provide some choice of the location provider. I agree that it would be good for user privacy and functionality if browsers supported geolocation technologies that didn't require sending a list of WiFi IDs to a third party; I suspect that as GPS sensors are more often integrated into smartphones and laptops, we'll see browsers that let you use GPS sensing for the W3C Geolocation API. It might also be nice to have a feature for desktop computers where the location can be manually specified in browser settings, this would also be compatible with the current spec.

Zn answered 18/11, 2010 at 23:38 Comment(2)
"It might also be nice to have a feature for desktop computers where the location can be manually specified in browser settings" - nice ideaSolomon
@Solomon there are addons like Location Guard to spoof the data and you can even do it without addons, for example with Firefox in about:config by setting the value of geo.provider.network.url to something like data:application/json,{"location": {"lat": 40.7590, "lng": -73.9845}, "accuracy": 27000.0} (makeuseof.com/tag/…)Gentlefolk
H
51

First, an amazing demo

Try this in Chrome.

How it works

Here is your answer. Click on "How Google Chrome determines your location".

From that page:

If you allow Google Chrome to share your location with a site, the browser will send local network information to Google Location Services to get an estimate of your location. The browser can then share your location with the requesting site. The local network information used by Google Location Services to estimate your location includes information about visible WiFi access points, including their signal strength; information about your local router; your computer's IP address. The accuracy and coverage of Google Location Services will vary by location.

Google Chrome saves your location information so that it can be easily retrieved. This information is periodically updated; the frequency of updates depends on changes to your local network information.

Also, I believe that Google Location Services contains a database built from data collected by Google Street View vans as they match locations with WiFi signals from routers (or at least used to).

Accessing the database

As for the database (Google Location Services), this SO question will help you access it.

Handoff answered 18/11, 2010 at 10:12 Comment(11)
That's insane. I did the test, it pinpointed EXACTLY where i am - i'm talking exactly, to the house on the street. I would be happy with figuring out my neighborhood, but how would it find which house i'm at? insane.Lashondalashonde
Yeah, pretty insane. Basically, it finds out what house you're in based on the broadcasts of the router you're using, which Google has marked as being at your house's location.Handoff
Really valuable stuff - also since my company has a location based site, would be awesome to come to the homepage, and tailor it to where you are. How is this HTML5 though, from what i'm seeing it's just Google, not HTML-5 specific?Lashondalashonde
Well, in order to use Google Location Services, you need to provide it data on the wireless signals around you and on your local router. That part of it requires HTML5.Handoff
@Lashondalashonde @Handoff It's only part of HTML5 in a marketing sense: isgeolocationpartofhtml5.comErvin
@robertc: But it's part of the official API. Can you elaborate?Handoff
@Handoff It is an official W3C standard, but created by a different group (the Geolocation Working Group) than the HTML5 working group. It's not technically a part of the HTML5 standard, it's a separate open standard.Zn
yeah, that's what i figured. i'm not sure how reliable this is. good to see technologies like this emerge though.Lashondalashonde
Interesting. Firefox thinks I'm downtown, but Chromium puts the dot on my house. From that article I understand that the wifi-network data it uses is collected from people using Android phones and no longer from the street cars. Interesting.Velmaveloce
That html5demos.com/geo demo doesn't work any more ... because Chrome's geolocation is disabled unless it's for an https page.Cannonball
It fails on me for some reason.Aphoristic
Z
24

For what it's worth, the API specification itself is agnostic to the geolocation implementation. So while it's true that Mozilla Firefox and Google Chrome both rely on network-enabled geolocation via Google's Location Service database, that's not a requirement of the standard. For example, Mobile Safari on your iPhone will in some cases use GPS rather than WiFi-triangulation or cell-site geolocation, depending on what location service is most accurate and accessible at a given moment.

And we can hope that future browsers will provide some choice of the location provider. I agree that it would be good for user privacy and functionality if browsers supported geolocation technologies that didn't require sending a list of WiFi IDs to a third party; I suspect that as GPS sensors are more often integrated into smartphones and laptops, we'll see browsers that let you use GPS sensing for the W3C Geolocation API. It might also be nice to have a feature for desktop computers where the location can be manually specified in browser settings, this would also be compatible with the current spec.

Zn answered 18/11, 2010 at 23:38 Comment(2)
"It might also be nice to have a feature for desktop computers where the location can be manually specified in browser settings" - nice ideaSolomon
@Solomon there are addons like Location Guard to spoof the data and you can even do it without addons, for example with Firefox in about:config by setting the value of geo.provider.network.url to something like data:application/json,{"location": {"lat": 40.7590, "lng": -73.9845}, "accuracy": 27000.0} (makeuseof.com/tag/…)Gentlefolk
E
12

In Firefox open a new tab and type in the address about:config. Go past the warning message and type geo.wifi.uri into the filter box, you are now looking at the web service Firefox uses for determining your location.

Ervin answered 18/11, 2010 at 10:13 Comment(0)
G
8

From Firefox's "How does it work":

When you visit a location-aware website, Firefox will ask you if you want to share your location.
If you consent, Firefox gathers information about nearby wireless access points and your computer’s IP address. Then Firefox sends this information to the default geolocation service provider, Google Location Services, to get an estimate of your location. That location estimate is then shared with the requesting website.
If you say that you do not consent, Firefox will not do anything.

and from "How Chrome determines your location":

If you allow Google Chrome to share your location with a site, the browser will send local network information to Google Location Services to get an estimate of your location. The browser can then share your location with the requesting site. You should examine a website's privacy policy before sharing your location with them.

Goins answered 7/1, 2013 at 10:18 Comment(0)
W
3

My guess to the last question in update4 is that supposedly they are updating your location from time to time, based on what device you use. For example if you used only your PC to access the web, and there is no known wifi networks nearby then your location will be determined by IP address, however information about your network will be gathered, later say you connect iPhone or any other device with GPS to your same wifi network, and use GPS on it, google will match those GPS coordinates to your wifi SSID or IP address. So, after then whenever your browser on PC sends a request for geolocation, it will check if the IP and SSID match (and maybe bunch of other things too, like SSID's in neighborhood and so on), and if they match, it will return the location that was previously determined by your GPS equipped device. This is just a guess of course, but it could be so.. also, even if you have never connected any GPS equipped device to your network, but it still determines it accurately, that might be because of the wifi networks in neighborhood, that are already known by google.. that's an awesome work they do, for sure :)

Update:
       Firefox
       Google Chrome

Wharfage answered 8/3, 2012 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.