This google map feature to show visitor location and IP. I use script from MaxMind.com to generate IP to Longitude and Latitude. Then the datas I use for google map Latitude and Longitude.
If you want to create post like this just copy and paste code below, and post on your blog. But Don't forget to create your on Google Map Api Key and replace with your own API Key.
<div id="map" style="border:solid 1px #D9D9D9;padding:3px;"></div>
<script type="text/javascript" src="http://hanantya.com/js/ip.aspx"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR GOOGLE API KEY"></script>
<script type="text/javascript">
google.load("maps", "2");
// Call this function when the page has been loaded
function initialize() {
var map = new GMap2(document.getElementById("map"),{ size: new GSize(550,320) } );
var center = new GLatLng(HInfoLatitude , HInfoLongitude);
map.setMapType(G_SATELLITE_MAP);
map.setCenter(center, 18);
var html = "<center>Your IP is : " + HInfoIP + "<br/> And your location at : " + HInfoCity + ", " + HInfoCountry + "</center>";
map.openInfoWindow(map.getCenter(),html);
var mapControl = new GMapTypeControl();
map.addControl(mapControl);
map.addControl(new GLargeMapControl());
}
if (typeof(HInfoIP) != "undefined" ){
google.setOnLoadCallback(initialize);
}
</script>



Cool!
That got my IP address and location correctly!
Nice,
I like to use it..
:-)
Post a Comment