Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DOC

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

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: "https://maps.googleapis.com/maps/api/geocode/json?key=set_your_api_key",
	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');
	   }
	}
});
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • thomas moore
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home