Skip to content

Commit

Permalink
Fix Geocoder Undefined offset bozdoz#190
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe13 committed Dec 28, 2022
1 parent 2690b7c commit 2ce2655
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions class.geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ private function osm_geocode ( $address ) {
$json = $this->get_url($geocode_url);
$json = json_decode($json);

return (Object) array(
'lat' => $json[0]->lat,
'lng' => $json[0]->lon,
);
if (isset($json[0]->lat) && isset($json[0]->lon)) {
return (Object) array(
'lat' => $json[0]->lat,
'lng' => $json[0]->lon,
);
} else {
throw new Exception('No Address Found.');
return false;
}
}

/**
Expand Down

0 comments on commit 2ce2655

Please sign in to comment.