Tuesday, October 30, 2012

Google Maps V3: get latitude and longitude by location name


var geocoder = new google.maps.Geocoder();
var address = "bogota, colombia";
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK)
  {
      // do something with the geocoded result
      var myLat = results[0].geometry.location.Ya;
      var myLng = results[0].geometry.location.Za;
      console.log("latitude: " +myLat );
      console.log("longitude: " +myLng );
  }
});

Reference:
http://stackoverflow.com/questions/3490622/get-latitude-and-longitude-based-on-location-name-google-maps-api

No comments: