Articles


How to get the Latitude and Longitude from Address?

How to get the Latitude and Longitude from Address?



Posted bysivaprasad,17th Feb 2017

With the help of Latitude and Longitude, we can easily locate the places.

Using the below code, You can get the Latitude and Longitude from Address.


$address = 'Trivandrum';
$map=file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false');
$map = json_decode($map, true);
if ($map['status'] = 'OK') {
  $latitude = $map['results'][0]['geometry']['location']['lat'];
  $longitude = $map['results'][0]['geometry']['location']['lng'];
}

Related Articles