Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
289 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...