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.

#### Features

- Solid API based on Geocoder PHP library
- Geocode and Reverse Geocode using one or multiple Geocoder providers (ArcGISOnline, BingMaps, File, GoogleMaps, Nominatim, OpeneStreetMap, etc);
- Results can be dumped into multiple formats such as WKT, GeoJson, etc ...
- The Geocoder Provider and Dumper plugins are extendable through a custom module;
- Submodule Geocoder Field provides Drupal fields widgets and formatters, with even more options;
- Geofield and Address field integration;
- Caching results capabilities, enabled by default;

#### Compatible modules

- Geofield (recommended location storage);
- Core String and Text fields, Address Field (Drupal 7) and Address (Drupal >= 8);
- Core Image and File modules (for Geo-Tagged and uploaded KML, Geojson, GPX files), into Drupal Geofield Format;
- Location (alternative location or address storage, only for D7 version);
- Geocoder autocomplete Provides a nice auto-complete text-widget;
- Geolocation (alternative location storage);

### Geocoder 1.x (Drupal 7 - unsupported | end if life)

#### Features

- Geocode Address or location data from any text or Addressfield value (using Google, Yahoo, Yandex, or MapQuest).
- Read Geotags from EXIF data in your photos.
- Convert any GPX Tracklog into a Linestring.
- Convert uploaded KML files into geometries.
- Convert uploaded or typed GeoJSON and WKT into geometries.
- Services module integration. You can easily transform Drupal into a general purpose geocoding server using REST, SOAP, XMLRPC etc.

#### 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 library - Version 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 the Geocoder 8.x-3.x version for D8/D9

1. Download the module running requiring it via composer. This will also download the Geocoder PHP library as willdurand/geocoder 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

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

- remove the Geocoder 8.x-2.x branch before ($ composer remove drupal/geocoder), and make sure also its dependency willdurand/geocoder": "^3.0" library is removed.
- require the new default Geocoder 3.x version ($ composer require drupal/geocoder)
- choose the Geocoder Provider you want to use and also add it as a required dependency to your project;
- run the database updates, either by visiting 'update.php' or running the '$ drush updb' command;
- set back (update) the Geocoding & Reverse Geocoding settings for each field you previously applied them;

Further Detailed Documentation and APIs provided in the Geocoder 3.x Readme.md file.

## Geocoder 4.x (Drupal 9/10)

This branch is a parallel copy of the Geocoder 3.x branch requiring the php-http/guzzle7-adapter, thus compatible with Guzzle 7 (that is a possible dependency since Drupal 9.4 and a requirement for Drupal 10). At the moment this branch still have incompatibilities with packages locked to php-http/guzzle6-adapter dependency (see issue #3283651). Further Detailed Documentation and APIs 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. (For more info refer to this Issue Comment.