Last updated 13 January 2018. Created on 11 March 2011.
Edited by itamair, dbjpanda, dbt102, exior. Log in to edit this page.

Geofield is a Drupal 7 (& Drupal 8) module that provides a field type for storing geographic data. This data can be attached to any entity, e.g., nodes, users and taxonomy terms. Geofield provides different widgets for data input and formatters for data output.

The Geofield module can store data as Latitude and Longitude, Bounding Box and Well Known Text (WKT) and it supports all types of geographical data: points, lines, polygons, multitypes etc.

It integrates with other mapping modules such as:

  • Geofield Map: an advanced, complete and easy-to-use Geo Mapping solution for Drupal 8, based on Geofield
  • OpenLayers: A very powerful mapping system based on the OpenLayers JavaScript library.
  • Static Map: Simple maps based on Google Maps
  • Leaflet: Moderately powerful mapping system based on the Leaflet JavaScript library
  • Geocoder: Geocode string & text addresses or file-uploads into Geofield locations and viceversa (Reverse Geocode)

and more ...

Install

For Drupal 7 version all you need to do is install the geoPHP module, which is required by geofield.

The Drupal 8 version of Geofield module needs to be installed using Composer to manage Drupal site dependencies, which will also download the required GeoPHP library dependency.
It means simply running the following command from your project root (where the main composer.json file is sited):

$ composer require 'drupal/geofield_map'

and then enable the module in the usual way, from the extend/modules backend
interfaces or via drush with the following command:

$ drush en geofield

Add a geofield to content

You can add geographical information to an entity (content type, user, taxonomy term or comment) by adding a geofield.

To add a geofield to e.g., a "Basic Page" go to /admin/structure/types/manage/page/fields/

Add a new field of the field type "Geofield", and choose the preferred widget, e.g., "OpenLayers Map". Configure the field according to the chosen options.

Display geographical information

Geofield Map

Geofield for Drupal 7 comes with the basic but easy-to-use submodule Geofield Map that allows you to display geographical data in a Google map.

In Drupal 8 the external Geofield Map moduleis an advanced, complete and easy-to-use Geo Mapping solution for Drupal 8, based on Geofield

OpenLayers (for Drupal 7 version)

For more advanced and flexible data display you need to create and configure a map in OpenLayers 2.

If you use OpenLayers you need to enable the OpenLayers UI. After, you can set Geofield Formatter Map output as default map in /admin/structure/openlayers/. Choose "Geofield Formatter Map" in the field OpenLayers Default Map.

You can easily create your own map by cloning an existing one. Introduction to OpenLayers.
When you have configured a map in OpenLayers you must define to use the map for displaying data at /admin/structure/types/manage/page/display/.

Leaflet

Geofield integrates also with the lightweight map display tool Leaflet

Microdata & Schema.org

Geofield supports microdata, which can be used by scripts and search engines to extract the Geo information in a meaningful way.

When you have Microdata module enabled, you can configure your microdata output on the field configuration page. There are suggestions of appropriate Schema.org settings at the bottom of the form. Choose one and click "Use suggested mapping".

More info

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.