Google Maps API v3 - 基于 IP 的地理定位 [英] Google Maps API v3 - IP-based Geolocation

查看:42
本文介绍了Google Maps API v3 - 基于 IP 的地理定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人能够使用 Google Maps API v3 JavaScript 获取基于个人 IP 的地理位置?

Has anyone been able to get geo-location based on a person's IP to work using Google Maps API v3 JavaScript?

在我看来,即使是谷歌提供的示例也不起作用.

It seems to me that even the google provided example doesn't work.

http://gmaps-samples-v3.googlecode.com/svn/trunk/commonloader/clientlocation.html

问题:

  1. 这个例子适用于任何人吗?

  1. Does this example work for anyone?

如何使用 Google Maps API v3 获取基于个人 IP 的地理定位?

How do I get geolocation based on a person's IP to work using Google Maps API v3?

推荐答案

Q1: 它可以从这里使用,也可能在许多其他位置使用.但是请注意,从 IP 地址进行地理定位并不是一门非常可靠的科学.您将获得 ISP 的位置,该位置可能很远,此外,IP 到位置的数据库并不总是与最新更改保持同步,因此您可能没有特定 IP 的任何数据地址——这可能就是你的情况.

Q1: It works from here, and probably from many other locations. However note that geolocation from IP addresses is not a very reliable science. You will be getting the location of your ISP, which can be quite far away, and in addition the IP-to-location databases aren't always up to date with the latest changes, so you might not have any data for a particular IP address -- which is probably what is happening in your case.

MaxMind,它提供了一个流行的 IP 到位置数据库,在其数据库上发布了一些统计数据:

MaxMind, which offers a popular IP-to-location database published some statistics on its database:

问题 2:通过 Google Maps API v3 从 IP 地址获取地理位置的唯一方法是使用 您提供的示例.但是,如果您发现任何其他地理定位数据库,例如 MaxMind GeoLite City,对于您的国家/地区,您可能希望自己从 IP 地址进行地理定位,而不是将其委托给 Google 地图.

Q2: The only way to get the geolocation from an IP address through the Google Maps API v3 is by using the same method used in the example you provided. However if you find that any other geolocation database, like MaxMind GeoLite City, is more accurate for your country, you may want to do the geolocation from the IP Addresses yourself, instead of delegating it to Google Maps.

这篇关于Google Maps API v3 - 基于 IP 的地理定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆