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 purpose of this method is to return latitude and longitude according to a given address entered as a parameter. However, after performing the test with some addresses the error of not returning the data. I ran the test to copy the created url and paste it into the browser, which worked correctly.
Can anyone tell me why this happens?