5
Follow the method code:
function GetGeoCode($address) {
$geo= array();
$geocode = file_get_html('http://maps.google.com/maps/api/geocode/json?address=' . $address . '&sensor=false');
$output = json_decode($geocode);
echo 'http://maps.google.com/maps/api/geocode/json?address=' . $address . '&sensor=false';
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
$geo['lat']=$lat;
$geo['long']=$long;
return $geo;
}
The objective of this method is to return the latitude and longitude according to a given address inserted as parameter. However, after performing the test with some addresses the error of not returning the data. I performed the test to copy the created url and paste in the browser, which worked correctly.
Can anyone tell me why this happens ?
Thanks. I made some changes here according to what you sent me and it worked. However I will even follow the dirt of reading the documentation as there are still some exceptions that still do not return. My code is very ugly and very funny.
– Doug