sathish
sathish

Reputation: 800

Need to pass address instead of latlong - Google maps v3

I am using google maps v3, Currently it is working fine, if i pass the latitude and longitude in 'position'. But, I need to pass address instead of latitude and longitude.

var ll = new google.maps.LatLng(dat_values[i].lat, dat_values[i].lng);
var marker = new google.maps.Marker({
                position: ll,
                icon: myImage,
                shadow: myShadow,
             });

Kindly anyone suggest.

thanks,

Upvotes: 3

Views: 4462

Answers (2)

tc99
tc99

Reputation: 31

Here's another similar approach:

$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&sensor=false');

$output= json_decode($geocode);

$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;

From: http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/

Upvotes: 3

duncan
duncan

Reputation: 31922

You've have to use the Geocoder service to convert the address into a LatLng.

Upvotes: 1

Related Questions