且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IP 地理定位的准确度如何?

更新时间:2023-02-26 18:57:30

IP 地理位置真的是命中注定,这取决于用户的 ISP 分配 IP 的方式以及您正在使用的 IP 地理位置数据库.例如,我制作了一个简单的 PHP 脚本,IP2FireEagle,它会查找您的 IP.我发现数据库一直将我放在我所在位置以西 10 多公里处.更新我在 Host IP 中的条目并不是***的,因为它很快就被恢复了,大概是偶尔有人由我的 ISP 分配的 IP!话虽如此,我发现 Clarke 的坐标非常准确(并不是说它本身使用的是 IP 地理定位,而是 Skyhook 的 API 和他们的 WiFi 地理定位数据库).

IP geolocation is really hit-or-miss, depending on both how the user's ISP assigns IPs and on the IP geolocation database you're using. For instance, I made a simple PHP script, IP2FireEagle, which looks up your IP. I found that the database kept placing me 10+ km to the west of where I really was. Updating my entry in Host IP wasn't the greatest, as it soon got reverted, presumably by someone also occasionally assigned that IP by my ISP! That being said, I found that Clarke has very accurate coordinates (not that this it's using IP geolocation per se but rather Skyhook's API and their WiFi geolocation database).

如果它是您朋友的网站,并且您知道他们有 iPhone,我建议使用它的 浏览器对 navigator.geolocation.getCurrentPosition() 的支持.也就是说,通过 Javascript 获取位置并通过 AJAX 调用将其提交到您的服务器.更好的是,因为你想使用谷歌地图,他们给你一个 关于如何获取朋友位置然后更新地图的简短教程.

If it's a website for your friends and you know they have iPhones, I would suggest using its browser's support for navigator.geolocation.getCurrentPosition(). That is, get the location via Javascript and submit it to your server via an AJAX call. Even better since you want to use Google Maps, they give you a short tutorial on how get your friends' locations and then update a map.