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, so as Reverse Geocode Geofield Points into String/Text Point addresses, and other Geocoder PHP library formats. In its Geocoder 1.x for Drupal 7 version, it also supports the Geolocation and Location modules for converting Points. This module makes available an API to convert the information you already have into geographic information. It support a variety of input formats and runs them through pluggable backends to produce geographic information. In addition to Latitude / Longitude points, this API also supports more complex geographies such as lines and polygons.

Compatible modules

Geocoder 1.x (Drupal 7)

Features

Requirements for D7

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

Tutorial

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

APIs

In addition to the GUI-based widget, geocoder also provides a nice general API for doing geocoding. Here's an example: out('json'); // List all available handlers $handlers = geocoder_handler_info(); dpm($handlers); ?> New geocoder handlers are easy to define. Simply create a new ctools plugin of the type "geocoder_handler". Find detailed documentation in the README.md file.

Geocoder 2.x (Drupal 8)

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

Features

Requirements for D8/D9

Installation for D8/D9

  1. Download the module running the following shell command from you project root (at the composer.json file level): $ composer require "drupal/geocoder" Note: this will also download the Geocoder PHP library as vendor/willdurand/geocoder
  2. Enable the module via Drush $ drush en geocoder or the website back-end/administration interface;
  3. Eventually enable also the submodules: geocoder_field, geocoder_geofield, geocoder_address;

Detailed Documentation and APIs

Find detailed documentation, also on its APIs in the README.md file.

Geocoder 3.x (Drupal 8/9)

This is an evolution of the Geocoder 2.x module, 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 the Geocoder 8.x-3.x version for D8/D9

  1. Download the module running the following shell command from you project root (at the composer.json file level): $ composer require "drupal/geocoder:^3.0@beta" Note: this will also download the Geocoder PHP library as willdurand/geocoder": "^4.0" library
  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 that as a possible geocoder provider choice in the "add provider" options of the Geocoder module settings page ('/admin/config/system/geocoder')

Upgrading from Geocoder 2.x to 3.x

Geocoder 3.x is not back compatible with Geocoder 2.x and no upgrade path has been provided so for general and fields configurations settings. At the moment, upgrading to Geocoder 3.x requires a complete uninstall and removal of Geocoder 2.x with the following steps:
  1. Uninstall Geocoder 2.x, via Drupal backend or with `drush pmu geocoder`
  2. Remove Geocoder 2.x via composer: `composer require drupal/geocoder`
  3. Make sure also its dependency willdurand/geocoder": "^3.0" library is removed
Further Detailed Documentation and APIs provided in the Geocoder 3.x Readme.md file.