[BNM] gpoint
Alex Beston
alex.beston at gmail.com
Thu Mar 9 02:24:33 GMT 2006
tried to do this but its not working.
damn.
the gpoint of google maps isnt positioning the data from lat/long from
maxminds[1] module so that i can show the mapped ip.
annoying.
the gpoint relies on a scripted change of id=map and i think the runtime
usage of the latitude / longitdude isnt working within the DOM I.E. the php
insertion of the varable is being put after the javascript is run meaning
that google map is seeing nothing data rather what comes from the maxmind
function.
ok heres the code:
<html>
<head><title>find an ip's details</title>
<script src="http://maps.google.com/maps?file=api&v=1&key=[deleted["
type="text/javascript"></script>
</head>
<body>
<form method="post" action="find-location.php">
ip number: <input type="text" name="ip" />
</form>
<?php
$ip = $_POST["ip"];
#echo $ip;
#exit();
if(!$ip)
exit("no ip number!");
include("/usr/local/share/GeoIP/geoip.inc");
include("/usr/local/share/GeoIP/geoipcity.inc");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);
echo "IP number: ".$ip."<br />";
#echo "Country code: ".geoip_country_code_by_addr($gi, $ip)."<br />";
#echo "Country name: ".geoip_country_name_by_addr($gi, $ip)."<br />";
geoip_close($gi);
#exit();
$gi = geoip_open("/usr/local/share/GeoIP/GeoLiteCity.dat",GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, $ip);
print "country code: ".$record->country_code. "<br />";
echo "code3: ". $record->country_code3. "<br />";
echo "country name: ". $record->country_name . "<br />";
echo "region: ". $record->region . "<br />";
echo "city: ". $record->city . "<br />";
echo "postal code: ". $record->postal_code . "<br />";
echo "latitude: ". $record->latitude . "<br />";
echo "longitude:". $record->longitude . "<br />";
echo "dma code: ". $record->dma_code . "<br />";
echo "area code: ". $record->area_code . "<br />";
geoip_close($gi);
echo "
<div id="map" style="width: 500px; height: 400px"></div>
<script type='text/javascript'>
var map = new GMap(document.getElementById('map'));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var point = new GPoint($record->latitude , $record->longitude ) ;
var marker = new GMarker(point);
map.addOverlay(marker);
map.centerAndZoom(new GPoint($record->latitude , $record->longitude ), 4);
</script>";
?>
</body>
</html>
any ideas why i cant see the marked tag for the servers lat/long much
appreciated
Alex :)
[1] http://www.maxmind.com/download/geoip/api/php/
More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service