Online Forum To Support Coders With Technical Assistance - Read Write Execute

How to get latitude and longitude from address in php

Ankit Agrawal
Ankit Agrawal
Published on July 13, 2015 · 1 min read

you can get latitude and longitude by using google map api

$userAddress = urlencode ("Malviya Nagar Jaipur");
$aAddressData = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$userAddress&sensor=false");
$aAddressDataDecode = json_decode($aAddressData);
$userLatitude = $aAddressDataDecode->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$userLongitude =	$aAddressDataDecode->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article How to align a div in center? Next Article → How to get post image url in wordpress