Chrome seems to be very accurate in detecting my location. How does it do it? Can you point me to the source code?
That's because Google will try to detect your location based on the IP address. Sometimes location databases have incorrect information and end up determining that you are in a different country.
Every Android device acts therefore as data collector. You can read more about this here. Since most access points are static in their position and only cover a small area - the coverage radius is approximately 100m - they are ideal anchors for a good location fix without GPS.
It uses an algorithm which analyzes your Hostname and IP address to determine your location. This information gathered often points to the location of your ISP. However, with more sophisticated systems it may also gather your city. Using the above methods geo-tracking can also be done when registering on a website.
Geolocation can be calculated based on:
See the W3C Geolocaton API and Google Gears API (which Chrome's/W3C Geolocation API is based on).
Chromium's geolocation source code can be viewed online.
Your location can be obtain using different services and hardware available on your device. The most common ones are: GPS, wifi information, cell towers. Alternatively there is also IP lookup, however this is not very accurate and does not involve anything special on your device.
In your case most likely information about your wifi network was used. There are huge databases which connect wifi networks to a location, created by cars with GPS & Wifi (e.g. Google Street View cars). The transmission from your computer to the server is done according to W3C Geolocation API Specs, which is part of HTML5.
Chrome Source for this? Here is a entry point to start off from. Or if you prefer the old fashioned file browser: http://src.chromium.org/svn/trunk/src/chrome/browser/geolocation/
Implementation files for localization via wifi:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With