This module is a Drupal wrapper/implementation for the Geocoder PHP library: "The most featured Geocoder library written in PHP, which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations".

It is commonly used to automatically Geocode string/text Point addresses and WKT Geometries into Geofield, as well as to Reverse Geocode Geofield Points into String/Text Point addresses, and other Geocoder PHP library formats.

Features

Included Submodules

The following submodules are bundled with the Geocoder package and provide extended integration capabilities:

Compatible and Recommended Modules


Geocoder 1.x (Drupal 7 — unsupported | end of life)

Features

Requirements for D7

All you need to do is install the geoPHP module, which is required by geocoder.

There's a nice video tutorial on using geocoder, addressfield, and geofield here.

Find detailed documentation in the README.md file.


Geocoder 2.x (Drupal 8 — unsupported)

This is a complete rewrite of the Geocoder module, based on the Geocoder PHP libraryVersion 3.x.


Geocoder 3.x (Drupal 8/9 — unsupported)

This is an evolution of the Geocoder 2.x module (deprecated), based on the Geocoder PHP library — Version 4.x.
Starting with this version the Geocoder providers are config entities, whereas in earlier versions the provider settings were stored in simple configuration. An upgrade path is provided but any code that was relying on the old simple config will need to be updated to use the config entities instead.
An upgrade path is provided but any code that was relying on the 2.x simple config will need to be updated to use the config entities instead.

Installation of the Geocoder 8.x-3.x version for D8/D9

  1. Download the module by requiring it via Composer. This will also download the Geocoder PHP library as willdurand/geocoder.
  2. Enable the module (and its sub-modules) via Drush.
  3. Choose the Geocoder Provider you want to use and also add it as a required dependency to your project. For example if you want to use Google Maps as your provider:
    $ composer require geocoder-php/google-maps-provider
    (You will find it as a possible geocoder provider choice in the "add provider" options on the Geocoder module settings page at /admin/config/system/geocoder.)

Upgrading from Geocoder 2.x to 3.x

When upgrading to the new Geocoder 8.x-3.x branch you would need to:

Further detailed documentation and APIs are provided in the Geocoder 3.x README.md file.


Geocoder 4.x (Drupal 9, 10, 11)

This is the current stable and recommended branch. It is a parallel evolution of the Geocoder 3.x branch, requiring php-http/guzzle7-adapter and therefore compatible with Guzzle 7 (a requirement for Drupal 10+). It also supports the willdurand/geocoder v5 library, which introduces PHP 8.4 compatibility and a range of upstream bug fixes.

Further detailed documentation and APIs are provided in the Geocoder 4.x README.md file.

How to seamlessly upgrade to Drupal 10 & Geocoder 4.x

When preparing for an upgrade to Drupal 10 we recommend that you widen your Composer version constraints to allow either 3.x or 4.x.
Edit composer.json the following way:

  "require": {
  ...
  "drupal/geocoder": "^3.20 || ^4.0",
  ...
  }

This will allow the module to be automatically upgraded when you upgrade Drupal core (refer to this Issue comment for more info).