Visitor Location by IP - Geolocation
In this tutorial, i will teach you how to get user location by using free maxmind geolocation service. This is not what you expected- HTML5 Geolocation. HTML5 is different from geolocation. Currently, some browsers don't support geolocation. The browsers that support it requests for users permission first. So, i think its better to continue using geolocation by IP if the goal is just to prepopulate form data. The geolocation code is given below:
<html>
<head>
<title>Prepopulate Form data using maxmind geolocation- By Ohwofosirai Desmond</title>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
</head>
<body>
<ul style="list-style:none; padding:0">
<li><em>City: </em></li>
<ul style="list-style:none; padding:0">
<li><script language="javascript">document.write(geoip_city());</script></li>
</ul>
<li><em>Country: </em></li>
<ul style="list-style:none; padding:0">
<li><script language="javascript">document.write(geoip_country_name());</script></li>
</ul>
<li><em>Zip Code: </em></li>
<ul style="list-style:none; padding:0">
</ul>
<li>If you would like to include a map, you may do the following to get latitude and longitude:</li>
<li><em>Country Code: </em></li>
<ul style="list-style:none; padding:0">
<li><script language="JavaScript">document.write(geoip_country_code());</script></li>
</ul>
<li><em>Latitude: </em></li>
<ul style="list-style:none; padding:0">
<li><script language="JavaScript">document.write(geoip_latitude());</script></li>
</ul>
<li><em>Longitude: </em></li>
<ul style="list-style:none; padding:0">
<li><script language="JavaScript">document.write(geoip_longitude());</script></li>
</ul>
<li>Then pass the longitude and latitude codes to your map service provider(e.g google map) for reverse engineering</li>
</ul>
</body>
</htmlm
0 comments:
Post a Comment
Leave a comment