Combining Maxmind GeoIP with Google Maps iFrame

This is a quick script which uses Maxminds geoip location db downloadable for free from here with Google Maps iFrame. I haven’t tested this enough to find out if Google restrict the number of requests by referrer but you could always put a meta refresh page in the iframe to blank the referrer if thats a problem.

// you might have to change the first three lines
$gpath = getcwd() . "/geoip/GeoIPCity.dat"; // to where your db is
include("geoip/");  // to where your .inc file is
$gi = geoip_open($gpath,GEOIP_STANDARD);
$record = geoip_record_by_addr($gi,$myip);
$city = $record->city;
$lat = $record->latitude;
$long = $record->longitude;
$countrycode = $record->country_code;
<iframe frameborder="0" marginwidth="0" marginheight="0" border="0" style="border:0; margin:0; width:340px; height:200px; -moz-border-radius: 15px; border-radius: 15px; border:3px solid #F00;" src=";latlng=<?php echo $lat; ?>%2C<?php echo $long; ?>" scrolling="no" allowtransparency="true"></iframe>

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *