How to get the Latitude and Longitude from Address?

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'];

 

}