Now easy Get the lat long coordinates from an address. Type the address which would include the name of the street,city/town, state and country name to get more accurate lat long value.
Get Lat Long By Address:
//Make Address
$address = $address.",".$area.",".$city.",".$country;
$preparedAddress = str_replace(' ','+',$address);
//Google Api
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$preparedAddress.'&sensor=false');
$output= json_decode($geocode);
echo $lat = $output->results[0]->geometry->location->lat;
echo $long = $output->results[0]->geometry->location->lng;
1 2 3 4 5 6 7 8 9 10 11 |
//Make Address $address = $address.",".$area.",".$city.",".$country; $preparedAddress = str_replace(' ','+',$address); //Google Api $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$preparedAddress.'&sensor=false'); $output= json_decode($geocode); echo $lat = $output->results[0]->geometry->location->lat; echo $long = $output->results[0]->geometry->location->lng; |