Back to Top

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

Updated 29 February 2024

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');
	   }
	}
});

Start your headless eCommerce
now.
Find out More
. . .

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