Quantcast
Channel: Webkul Blog
Viewing all articles
Browse latest Browse all 5553

Get Latitude and Longitude Of Address From Google Map API In JSON Formate Using Ajax

$
0
0

First you include jQuery Lib. File in Your Page….

in following example #latitude and #longitude are Ids of HTML elements where we want to display them

var address='B-56+Sector-64+Noida+up+india';//address which you want Longitude and Latitude
jQuery.ajax({
	type: "GET",
	dataType: "json",
	url: "http://maps.googleapis.com/maps/api/geocode/json",
	data: {'address': address,'sensor':false},
	success: function(data){
	    if(data.results.length){
	        jQuery('#latitude').val(data.results[0].geometry.location.lat);
		jQuery('#longitude').val(data.results[0].geometry.location.lng);
	    }else{
		jQuery('#latitude').val('invalid address');
		jQuery('#longitude').val('invalid address');
	   }
	}
});
Facebook Twitter Email Reddit Stumbleupon

Viewing all articles
Browse latest Browse all 5553

Trending Articles