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

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

问题描述

有没有人能够根据个人的知识产权使用Google Maps API v3 JavaScript获取地理位置?



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



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



问题


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

  2. $ b
  3. 如何根据个人IP使用Google Maps API v3获取地理定位?

  4. h2_lin>解决方案

Q1:它可以在这里使用,也可能来自其他许多地方。但请注意,来自IP地址的地理位置不是一门非常可靠的科学。您将获得ISP的位置,这可能相当遥远,此外,IP到位置数据库并不总是与最新更改保持一致,因此您可能没有任何特定IP的数据地址 - 这可能是你的情况发生了什么。

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



Q2:通过Google Maps API v3从IP地址获取地理位置的唯一方法是使用与您提供的示例。但是,如果您发现其他任何地理位置数据库(例如 MaxMind GeoLite City )对您而言更准确国家,您可能想要自己从IP地址中进行地理定位,而不是将其委托给Google地图。


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

Question:

  1. Does this example work for anyone?

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

解决方案

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, which offers a popular IP-to-location database published some statistics on its database:

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天全站免登陆