Archive for the 'Geo' Category

Setting up MaxMind GeoIP Lib to work with Google Maps

Saturday, May 24th, 2008

Google 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']);
}