Typically, we used Drupal Cloud Console's Google Maps Geocoding API for Geolocation search, but a customer asked us to use OSM Nominatim instead.
I first had to find out, how to enable this provider in Drupal's Geocoder Module for Drupal 9 but finally found out (as documented on the Geodcoer providers page), that providers can be provided via composer:
composer require geocoder-php/nominatim-provider
Afterwards you can select and enable them on the Geocoder admin page: admin/config/system/geocoder/geocoder-provider
Eventually you'll have to clear cache first!
As you can see on the screenshot, the module provides a link for a list of geocoder providers: https://packagist.org/providers/geocoder-php/provider-implementation
Nominatim works simply great! And without any costs for small projects!
Should you encounter a composer error like this:
- Problem 1
- - geocoder-php/common-http[4.1.0, ..., 4.4.0] require php-http/client-implementation ^1.0 -> could not be found in any version, but the following packages provide it:
- - symfony/http-client Provides powerful methods to fetch HTTP resources synchronously or asynchronously
- - php-http/guzzle6-adapter Guzzle 6 HTTP Adapter
- - symfony/symfony The Symfony PHP framework
- - php-http/curl-client PSR-18 and HTTPlug Async client with cURL
- - php-http/guzzle7-adapter Guzzle 7 HTTP Adapter
- - kriswallsmith/buzz Lightweight HTTP client
- - php-http/mock-client Mock HTTP client
- - php-http/socket-client Socket client for PHP-HTTP
- - php-http/guzzle5-adapter Guzzle 5 HTTP Adapter
- - php-http/react-adapter React HTTP Adapter
- - voku/httpful A Readable, Chainable, REST friendly, PHP HTTP Client
- - php-http/buzz-adapter Buzz HTTP Adapter
- - php-http/cakephp-adapter Cake adapter for PHP-HTTP
- - code-tool/curl-client cURL client
- - windwalker/http Windwalker Http package
- - swisnl/php-http-fixture-client Fixture client for PHP-HTTP
- - jorge-matricali/http-client A wrapper of libcurl that implements PSR-7 HTTP message interface.
- - windwalker/framework The next generation PHP framework.
- - juststeveking/http-slim A slim psr compliant http client to provide better interoperability.
- - betalabs/guzzle6-adapter Guzzle 6 HTTP Adapter
- ... and 33 more.
- Consider requiring one of these to satisfy the php-http/client-implementation requirement.
- - geocoder-php/nominatim-provider[5.5.0, ..., 5.5.1] require geocoder-php/common-http ^4.1 -> satisfiable by geocoder-php/common-http[4.1.0, 4.2.0, 4.3.0, 4.4.0].
- - Root composer.json requires geocoder-php/nominatim-provider ^5.5 -> satisfiable by geocoder-php/nominatim-provider[5.5.0, 5.5.1].
- Potential causes:
- - A typo in the package name
- - The package is not available in a stable-enough version according to your minimum-stability setting
- see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- - It's a private package and you forgot to add a custom repository to find it
You may have to install one of the suggested dependencies which matches your environment best. For Drupal 9 I chose the Symfony implementation:
composer require symfony/http-client