Setting up MaxMind GeoIP Lib to work with Google Maps
May 24th, 2008Google maps has a pretty extensive open API that gives users the ability to create really fancy maps for their websites. The way you comunicate with the google API is via their own JavaScript Libraries.
The first thing you need to do is get a developer key
http://code.google.com/apis/maps/signup.html
Then you need you drop the sample HTML on your website and veriy that it works. Like I did here:
http://www.chrisdevbox.com/lab/googlmap/
Then you need to install MaxMind C API library and download their database. You also need to install the PHP client libraries and recompile PHP. I added instructions on how to do that here:
http://wiki.chrisdevbox.com/index.php/Setting_up_GeoIP_by_MaxMind
Here is the final example:
http://www.chrisdevbox.com/lab/googlmap/google-map-by-ip.php
Here is the PHP section, as you can see after installing the client API you don’t have to do a lot of coding to maket it work…
$localzone = null;
if(geoip_db_avail(1))
{
$localzone = geoip_record_by_name($_SERVER['REMOTE_ADDR']);
}

June 25th, 2008 at 10:14 am
Hi
i ve done the example. but when a friend of mine visits your map he gets an other city than on my map? are you using an other database?
thx
chris
June 25th, 2008 at 1:59 pm
Yeah, unfortunately yes, that’s a behavior that can’t be fixed. If you ISP/Node is on a different city, meaning your IP originates from a city that’s not yours then the map will give you that other city…
July 23rd, 2008 at 4:14 am
Are the codes working for the IP2Location C API?
http://www.ip2location.com/c.aspx
We are using the IP2Location and could like to have the similar features.
July 23rd, 2008 at 9:21 am
Yeah, ip2location is very similar to MaxMind. They both have a pretty complete IP range / geo mapping binary database. You can pretty much do the same thing, should not be a problem.