How does Chrome know my geolocation?

前端 未结 6 1267
囚心锁ツ
囚心锁ツ 2020-12-24 13:16

Chrome seems to be very accurate in detecting my location. How does it do it? Can you point me to the source code?

相关标签:
6条回答
  • 2020-12-24 13:34

    I think they use your IP address and a geolocation service like http://www.ip2location.com/ or (more likely) their own geolocation database/service)

    0 讨论(0)
  • 2020-12-24 13:35

    Geolocation can be calculated based on:

    1. GPS (if available)
    2. Available wi-fi networks and signal strengths
    3. Available cell towers and signal strengths
    4. IP Address lookup

    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.

    0 讨论(0)
  • 2020-12-24 13:35

    Recently i worked on HTML 5 Geo-location assignment. Its supported in all modern browsers (IE9, Safari, FF, Opera).
    But when I came to Chrome its not supported. I spent several hours in fixing this.
    Finally I found a a solution:

    The geolocation in Chrome is turned off by default. To activate it, users must go to their Chrome shortcut and add --enable-geolocation to the end of the target line, under the Shortcut tab.

    0 讨论(0)
  • 2020-12-24 13:36

    They look at several things: -> The unique identifiers (SSID) of wireless networks at your location and signal strengths. -> IP address (your public IP address) -> GPS (if available) -> Mobile network location data (if available)

    0 讨论(0)
  • 2020-12-24 13:43

    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:

    • wifi_data_provider_mac.cc
    • wifi_data_provider_linux.cc
    • wifi_data_provider_win.cc
    0 讨论(0)
  • 2020-12-24 13:52

    a browser on a pc does not have a gps, however it has an external ip address (usually the router's external ip address). if other components behind the same router has a gps - this pins location to that ip address and via location services attaches this location to the browser.

    0 讨论(0)
提交回复
热议问题