Tuesday, September 20, 2016

How Can I Find the Latitude and Longitude from Address using Javascript?

If you want to place your address in google map then easy way to use following.

function codeAddress(_address,_callback) {

  var geocoder = new google.maps.Geocoder();
  geocoder.geocode( { 'address': _address}, function(results, status) {
   if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    _callback(results[0].geometry);
   } 
   else {
    alert("Geocode was not successful for the following reason: " + status);
   }
  });
 };



codeAddress('Central Park Denver',function(_coord){
//use the coordinates :: _coord

});

Try our Google Map WordPress Plugin

No comments:

Post a Comment