This extension integrates the Geocoder PHP library into Contao CMS. It's designed for other extensions to use a common geocoder implementation.
- Geocoder service for other extensions
- Built in support for
nominatim
andgoogle maps
- Extandable for other providers
- Database driven configuration of providers in Contao backend
- Application driven configuration of providers
- API endpoint for geocode queries
- Contao
^4.13 || ^5.3
- PHP
^8.2
composer require cowegis/contao-geocoder ^1.0.0
# Optional for Nominatim support
composer require geocoder-php/nominatim-provider ^5.5
# Optional for Google Maps support
composer require geocoder-php/google-maps-provider ^4.6
Optional application configuration
# app/config/config.yml
cowegis_contao_geocoder:
providers:
foo:
title: "Foo Geocoder"
type: "google_maps"
google_api_key: "ABC"
bar:
title: "Bar Geocoder"
type: "nominatim"
default_provider: "bar"
<?php
use Cowegis\ContaoGeocoder\Provider\Geocoder;
final class MyService
{
private $geocoder;
public function __construct(Geocoder $geocoder)
{
$this->geocoder = $geocoder;
}
public function geocode(string $address) : \Geocoder\Location
{
return $this->geocoder
// Optional use a specific geocoder. Otherwise the default provider is used
->using('foo')
->geocodeQuery(\Geocoder\Query\GeocodeQuery::create($address))
->first();
}
}
This extension is licensed under LGPL-3.0-or-later