Monday 3 July 2017

How to obtain longitude and latitude for a street address using JavaScript.

How to obtain longitude and latitude for a street address using JavaScript.
Description:


In this example we explain that how to get longitude and latitude for a address using JavaScript for google map. Or how to obtain longitude and latitude for a street address for google map using JavaScript. Or how to fetch longitude and latitude for country or city address for google map using JavaScript.

Below is the code that demonstrate how to get the longitude and latitude for address or for based on zip code in google map using JavaScript.
Code:

var geocoder = new google.maps.Geocoder();
var address = "Ahmedabad";
geocoder.geocode( { 'address': address}, function(results, status) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude+" and "+longitude);
  }
});



0 comments:

Post a Comment