Skip to content

ashishbansal-kmc/address-using-lat-long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Get Address from google map api using latitude and longitude. Note: Please pass google map api key also

address-using-lat-long

function getaddress($lat,$lng)
{
  $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';
  $json = @file_get_contents($url);
  $data=json_decode($json);
  $status = $data->status;
  if($status=="OK")
  return $data->results[0]->formatted_address;
  else
  return false;
}

Example:

  $lat= 26.754347; //latitude
  $lng= 81.001640; //longitude
  $address= getaddress($lat,$lng);
  if($address)
  {
  echo $address;
  }
  else
  {
  echo "Not found";
  }

About

Get address from latitude and longitude

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published