HTML5 地理定位如何工作?
Chrome 和 Firefox 已实现 HTML 地理定位。
我的问题是:它是如何运作的?他们在本地是否有数据库并从提供商处获取信息然后尝试匹配它?
DB存储在哪里? 可以访问吗?
Update1:地理定位的唯一缺点是浏览器必须征求用户的许可,这对于可用性来说确实是一件坏事。我了解安全问题,但仍然不知道这将如何成为流行的解决方案。
Update2:Firefox 正在使用 Google WebService 来检测位置。考虑到他们现在是竞争对手,这看起来很奇怪。而且这种行为对我来说真的是出乎意料的......我希望每个浏览器都会有它的开启(可能是离线)解决方案。
Update3:那么浏览器实际上是使用您的无线网卡来嗅探路由器的?
Update4:浏览器到底向google webservice发送什么信息?检测到的 SSID 似乎没问题(如果谷歌根据他们的物理位置跟踪他们以在数据库中查找匹配信息,这是有道理的)但是它如何在谷歌没有扫描的国家/地区工作得这么好?您的浏览器发送的其他信息是您的 IP,但这不足以确定您的确切位置,对吗?
关于可能实现此功能的其他浏览器。他们应该怎样做呢?该 api 没有记录,只有旧的已弃用的 GEAR api 提供了一些线索。所以这并不是真正公开的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,一个令人惊叹的演示
在 Chrome 中尝试这个。
工作原理
这里就是您的答案。点击“Google Chrome 如何确定您的位置”。
从该页面:
另外,我相信 Google 定位服务包含一个由 Google 街景货车收集的数据构建的数据库,因为它们将位置与来自路由器的 WiFi 信号相匹配(或至少 曾经)。
访问数据库
至于数据库(Google 定位服务),这个 SO问题将帮助您访问它。
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:
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.
无论如何,API 规范本身与地理位置实现无关。因此,虽然 Mozilla Firefox 和 Google Chrome 确实都依赖于通过 Google 位置服务数据库进行网络支持的地理定位,但这并不是标准的要求。例如,iPhone 上的 Mobile Safari 在某些情况下将使用 GPS,而不是 WiFi 三角测量或蜂窝基站地理定位,具体取决于在给定时刻哪种定位服务最准确且最容易访问。
我们希望未来的浏览器能够提供一些位置提供商的选择。我同意,如果浏览器支持不需要向第三方发送 WiFi ID 列表的地理定位技术,这对用户隐私和功能都有好处;我怀疑,随着 GPS 传感器越来越多地集成到智能手机和笔记本电脑中,我们将看到允许您将 GPS 传感用于 W3C 地理定位 API 的浏览器。如果桌面计算机有一个功能,可以在浏览器设置中手动指定位置,这也可能会很好,这也与当前规范兼容。
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.
在 Firefox 中打开一个新选项卡并输入地址
about:config
。跳过警告消息并在过滤框中输入geo.wifi.uri
,您现在正在查看 Firefox 用于确定您位置的网络服务。In Firefox open a new tab and type in the address
about:config
. Go past the warning message and typegeo.wifi.uri
into the filter box, you are now looking at the web service Firefox uses for determining your location.来自 Firefox 的“它是如何工作的”:
以及“Chrome 如何确定您的位置” :
From Firefox's "How does it work":
and from "How Chrome determines your location":
我对 update4 中最后一个问题的猜测是,他们会根据您使用的设备不时更新您的位置。例如,如果您仅使用 PC 访问网络,并且附近没有已知的 wifi 网络,那么您的位置将由 IP 地址确定,但是有关您的网络的信息将被收集,稍后假设您将 iPhone 或任何其他设备连接到GPS 到您同一个 wifi 网络,并在其上使用 GPS,谷歌会将这些 GPS 坐标与您的 wifi SSID 或 IP 地址相匹配。因此,此后,每当您的 PC 上的浏览器发送地理定位请求时,它都会检查 IP 和 SSID 是否匹配(也许还有其他一些东西,例如附近的 SSID 等),如果匹配,它将返回之前由您配备 GPS 的设备确定的位置。当然,这只是一个猜测,但也可能是这样..而且,即使您从未将任何配备 GPS 的设备连接到您的网络,但它仍然可以准确地确定它,这可能是因为附近的 wifi 网络,谷歌已经知道了..他们所做的工作确实很棒:)
更新:
火狐浏览器
谷歌浏览器
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