2
Currently I use the lines of code below to list the city where I am through latitude and longitude, however, with the same coordinates, I want to list also the cities that are around, by mileage for example. Is it possible? I did a lot of research on this but couldn’t find a solution.
Follow the code I’m using to pull the current city:
$latitude = htmlspecialchars($_GET["latitude"]);
$longitude = htmlspecialchars($_GET["longitude"]);
$geocode = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng='.$latitude.','.$longitude.'&sensor=false');
$resultado = json_decode($geocode);
for($j=0;$j<count($resultado->results[0]->address_components);$j++){
$cn=array($resultado->results[0]->address_components[$j]->types[0]);
if(in_array("locality", $cn))
{
$s = $resultado->results[0]->address_components[$j]->long_name;
}
}
I would appreciate it if you would help me find a solution.
If the selected answer served, I would suggest taking Google and Google Maps from the tags and title of the question, because the answer does not get the results from Google.
– Bacco