Return to Snippet

Revision: 49956
at August 3, 2011 04:21 by uberdragon


Updated Code
<?php
$address = '201 S. Division St., Ann Arbor, MI 48104'; // Google HQ
$prepAddr = str_replace(' ','+',$address);

$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');

$output= json_decode($geocode);

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

echo $address.'<br>Lat: '.$lat.'<br>Long: '.$long;

?>

Revision: 49955
at August 3, 2011 03:27 by uberdragon


Initial Code
<?php

$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;

?>

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

Initial Description
Convert an address to geocode Latitude/Longitude positioning with PHP and Google Maps

Initial Title
get Latitude/Longitude from an address

Initial Tags

                                

Initial Language
PHP