Skip to content

Commit

Permalink
Fix for #37
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Aug 1, 2024
1 parent ce63a1f commit 6eb06bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes for Easy Address Field for Craft CMS

## 3.1.2 - 2024-08-01
### Fixed
- Fixed a crash when Nomanatim service isn't available ([#37](https://github.com/studioespresso/craft-easyaddressfield/issues/37))

## 3.1.1 - 2022-06-27
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "studioespresso/craft-easyaddressfield",
"description": "The only address field you need",
"type": "craft-plugin",
"version": "3.1.1",
"version": "3.1.2",
"keywords": [
"cms",
"craftcms",
Expand Down
12 changes: 8 additions & 4 deletions src/services/GeoLocationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ public function init()
*/
public function locate(EasyAddressFieldModel $model)
{
if (!$model->latitude && !$model->longitude and strlen($model->toString()) >= 2) {
$model = $this->geocodeOSM($model);
}
try {
if (!$model->latitude && !$model->longitude and strlen($model->toString()) >= 2) {
$model = $this->geocodeOSM($model);
}

return $model;
return $model;
} catch (\Throwable $e ){
Craft::error($e->getMessage(), __METHOD__);
}
}

private function geocodeOSM(EasyAddressFieldModel $model)
Expand Down

0 comments on commit 6eb06bb

Please sign in to comment.