是否可以从 HTTP 请求中获取(粗略的)手机位置
如果我没记错的话,谷歌在地图网站上就是这么做的。我知道谷歌的移动地图应用程序可以确定大致位置(我假设使用某种手机信号塔查找),但我似乎记得在移动浏览器上查看时该网站有点接近当前位置。
有人知道如何/如果可能吗? IP 地址是否会根据塔或区域而变化(似乎他们会使用运营商通用的某种网关)?
If memory serves me correctly, google does this for the maps site. I know google's mobile maps app can determine the rough location (I assume using some kind of cell tower lookup), yet I seem to remember the site getting somewhat close to the current location when viewing on a mobile browser.
Anyone know how/if that's possible? Does the IP address change based on the tower or area (seems like they'd be using some kind of gateway common to the carrier)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于常规 HTTP 请求,您唯一的选择是 GeoIP,但这只会为您提供国家/地区和地区。运营商也好不到哪儿去。
取决于应用程序和您使用的设备有多种地理定位选项,例如 iPhone 和 iPhone 等。 Android 浏览器支持 HTML5 地理 JavaScript 函数,因此您可以在页面中放置一些代码来向您发送位置。然而,这些都涉及一些客户端代码。
另一种选择涉及与网络进行交易,他们可以向您提供电话号码作为请求中的附加标头,然后您可以通过运营商的 API 查询该号码,以从网络获取手机的位置。然而,他们为此功能收取相当高的费用,并且精度可能从城市环境中的约 100m 到非常农村地区的 35Km 不等。
With a regular HTTP request the only option you have is GeoIP but this will only give you the country & operator no better.
Depending on the application & device you are using there are various option for geolocation, for example iPhone & Android browsers suport the HTML5 geo javascript functions so you could put some code in the page to send you the location. However these all involve some client side code.
The other option involves doing a deal with the networks, they can supply you the phone number as an additional header in the request and you can then query this number via an API from the operator to get the location of the phone from the network. However they charge a pretty penny for this function and the accuracy can vary from about 100m in an urban environment to 35Km in very rural areas.
1.) 通过查询网络详细信息来定位。
即使您通过查询网络或小区 ID 详细信息从已安装的应用程序中获取了大概位置, d 没那么可靠。您将无法根据该大致位置执行任何操作。
2.) 通过查询 IP 定位。
其次,在一个国家/地区,单个电信公司将拥有地理定位的 GPRS 或 EDGE 网关,并且网络上的所有设备都通过该网关连接到互联网。因此基本上您不能依赖 IP 的位置详细信息,因为这将是网关的 IP,而不是设备的 IP(在 EDGE 的情况下)。
1.) Location By querying Network Details.
Even if you get the approximate location from an installed app by querying network or cell-id details, it'd not be that reliable. You won't be able to perform anything based on that approximate location.
2.) Location By querying IP.
Secondly, in one country, a single telco will have it geo-stationed GPRS or EDGE gateways and all devices on network are connected to internet with that gateway. So basically you can't rely on location details by IP, because that would be the IP of the Gateway and not the IP of device(in case of EDGE).
我们使用 Google Gears 一段时间了,它可以在 Windows Mobile 5.0 及以上版本的设备上运行。谷歌最近停止了该服务。雅虎现已推出名为“雅虎火鹰”的项目。听起来不错,还没看。我还没有雅虎帐户。
We were using Google Gears for some time and that worked on Windows Mobile version 5.0 plus devices. Google recently stopped that service. Yahoo have now started something called Yahoo Fire Eagle. Sounds good, haven't yet checked it out. I dont have a Yahoo account, yet.
您有关于此的 Google API 文档:
http://code.google.com/apis/ gears/geolocation_network_protocol.html
希望有帮助...
You have Google API Documentation on this:
http://code.google.com/apis/gears/geolocation_network_protocol.html
Hope it helps...
有点晚了,但另一个没有提到的选项是 MaxMind 地理 IP 查找。输入 IP 地址,它将为您提供位置。有免费服务(带有简单的 API)可提供城市级准确性。还有一个收费的更准确的数据库。我在测试过程中注意到,城市地区有多个塔/IP 地址,MaxMind 数据库知道这些。您将获得位置信息以及电信提供商的信息。
http://www.maxmind.com/
A little late in the day, but another option not mentioned is the MaxMind geo IP lookup. Enter an IP address and it will provide you with a location. There is free service (with simple API) that provides city level accuracy. There is also a more accurate database available for a fee. I have noticed during testing that there are multiple towers / IP addresses in urban areas and the MaxMind database is aware of these. You'll get location, plus the telco provider.
http://www.maxmind.com/