Html HTML5 的 GeoLocation 究竟是如何工作的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3041113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How, exactly does HTML5's GeoLocation work?
提问by Dan
I know the browser shares my IP address and details of nearby wireless networks to determine my location, but what sort of info does it know about nearby wifi networks?
我知道浏览器会共享我的 IP 地址和附近无线网络的详细信息来确定我的位置,但是它知道关于附近 wifi 网络的哪些信息?
For example, where I live are no public wireless networks, and from my home I can see about 5 private networks, yet my location is determined within 20 meters. With there being no open networks nearby, how does Google determine my location? The only way I can think of is that Google mapped the locations of all wireless networks when they mapped streets for Street View.
例如,我住的地方没有公共无线网络,从我家可以看到大约5个私有网络,但我的位置在20米内。由于附近没有开放网络,Google 如何确定我的位置?我能想到的唯一方法是,谷歌在为街景绘制街道时,会绘制所有无线网络的位置。
I've searched about online, but all I can't find any specific details.
我在网上搜索过,但我找不到任何具体的细节。
回答by fmark
The data sent by Firefox to Google is for all visible access points, public or private. For each access point detected, it sends the following data to https://www.google.com/loc/json
:
Firefox 发送给 Google 的数据适用于所有可见的访问点,无论是公共的还是私有的。对于检测到的每个接入点,它会将以下数据发送到https://www.google.com/loc/json
:
"mac_address": "01-23-45-67-89-ab",
"signal_strength": 8,
"age": 0,
"SSID": "MyAccessPoint"
where
在哪里
mac_address
is the mac address of the WiFi node.signal_strength
is current signal strength measured in dBm.age
is the number of milliseconds since the WiFi node was detected.SSID
is the name or ESSIDof the WiFi node.
mac_address
是WiFi节点的mac地址。signal_strength
是以 dBm 为单位测量的当前信号强度。age
是自检测到 WiFi 节点以来的毫秒数。SSID
是WiFi 节点的名称或ESSID。
The georeferenced WiFi data used to geocode your request was collected when Google was driving around taking pictures for StreetView.
用于对您的请求进行地理编码的地理参考 WiFi 数据是在 Google 为街景拍摄照片时收集的。
It is important to note that, however, that this is how the HTML5 geolocation API is implmeneted on Firefox using Google's Geolocation Services. This is an implementation, not a specification.If your device has a built-in GPS, it is probably desirable that your HTML5 implementation queries the GPS directly, rather than using a geolocation service.
然而,重要的是要注意,HTML5 地理定位 API 就是使用 Google 的地理定位服务在 Firefox 上实现的。 这是一个实现,而不是一个规范。如果您的设备具有内置 GPS,则可能希望您的 HTML5 实现直接查询 GPS,而不是使用地理定位服务。
Even firefox implements this feature differently on Windows and Linux. Using a current Firefox on Windows, details of all visible WiFi nodes are sent to Google. Using a current Firefox on Linux, only details of the currently connected WiFi node is sent, due to the reliance on libiw
for access point data.
甚至 firefox 在 Windows 和 Linux 上也以不同的方式实现此功能。在 Windows 上使用当前的 Firefox,将所有可见 WiFi 节点的详细信息发送给 Google。由于依赖于libiw
接入点数据,在 Linux 上使用当前的 Firefox,仅发送当前连接的 WiFi 节点的详细信息。
As another answerer noted, Safari uses Skyhook Wireless's service which does much the same thing as Google's Location Services.
正如另一位回答者指出的那样,Safari 使用Skyhook Wireless的服务,它的作用与 Google 的定位服务大致相同。
回答by ceejayoz
Data is gathered by Skyhook Wireless (Wikipedia), and they make no distinction between public and private wifi points - they log the locations of all of them. I wouldn't be surprised if the Google Street View vans also logged location data for access points.
数据由Skyhook Wireless(维基百科)收集,它们不区分公共和私人 wifi接入点——它们记录了所有接入点的位置。如果谷歌街景货车也记录了接入点的位置数据,我不会感到惊讶。