Last active
April 26, 2016 10:11
-
-
Save alfredfrancis/ac5bc0fa6ec88bf6a03b172c0404b248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getCoordinates($location) | |
{ | |
$address = str_replace(" ", "+", $location); | |
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$location"; | |
$response = file_get_contents($url); | |
$json = json_decode($response,TRUE); | |
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']); | |
} | |
echo getCoordinates('gandhinagar,jaipur'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment