Geolocation API for Getting Users Address with example code ~ Web CodeHelpers

Geolocation API for Getting Users Address with example code

HTML5 Geolocation API for getting users address :
in past Article i wrote about the HTML5 Geolocation API in details, check it out in the below link
HTML5 Geolocation API 
In this article i like to show example how we use in realtime for getting of users address when ever they try to use your website,.

Your Current Location Address 
Live Demo : Your Location Show below  [Refresh]

Code for showing the current location address :

<!doctype html>
<script src=""></script>
$('#showAddressButton').html('Click Here Show your Address');
if (navigator.geolocation) {
function showPosition(position){
         var lat = position.coords.latitude,
           lng = position.coords.longitude;
var jqxhr = $.ajax( ""+lat+","+lng+"&sensor=true" )
 .done(function(data) { $('#showMapAddress').html(data.results[0].formatted_address);
 .fail(function() {
   $('#showMapAddress').html("Geo Error");
function showError(error){
   x = document.getElementById('showMapAddress');
       case error.PERMISSION_DENIED:
         x.innerHTML="User denied the request for Geolocation."
       case error.POSITION_UNAVAILABLE:
         x.innerHTML="Location information is unavailable."
       case error.TIMEOUT:
         x.innerHTML="The request to get user location timed out."
       case error.UNKNOWN_ERROR:
         x.innerHTML="An unknown error occurred."

}else {
alert("Your Browser does not Support Geolocation Feature");

<div id="showMapAddress"></div>


Post a Comment

Subscribe updates via Email