I am working on a project in CodeIgniter and I require lat
and lng
of a specific location. The code at the bottom was working fine but now $geo['status']
is showing QUERY_OVER_LIMIT
. How to solve it?
I also get the following warning:
undefined offset:0 error in $latlng['lat']= $geo['results'][0]['geometry']['location']['lat']; $latlng['lng']= $geo['results'][0]['geometry']['location']['lat'];
Thanks in advance. Here's my code:
$address = $this->input->post('key');
$geo = file_get_contents('http://maps.googleapis.com/maps/api/geoco/json?address='.urlencode($address).'&sensor=false');
$geo = json_decode($geo, true);
if ($geo['status'] = 'OK') {
$latlng['lat']= $geo['results'][0]['geometry']['location']['lat'];
$latlng['lng']= $geo['results'][0]['geometry']['location']['lat'];
echo json_encode($latlng);
} else {
echo 0;
}