Google Maps widget
HTML5 geolocation widget

Geolocation Field provides a field type to store geographical locations as pairs of latitude and longitude (lan,lng). The Drupal 8 version also provides a views proximity search plugin. Geolocation Field can be used with all fieldable entities like nodes, users, comments, taxonomy terms, etc.

Geolocation Field aims to provide a light-weight, easy-to-use and robust alternative to more complex solutions.

Drupal 8

The Drupal 8 version of Geolocation Field is a complete rewrite. Please test and open an issue to fix a bug or share your thoughts.

  • field storage of lat,lng pairs
  • basic lat,lng text input widget
  • basic lat,lng formatter with microdata output (rich snippet: twig template).
  • new HTML5 geolocation widget
  • new Google geocoder widget
  • configurable Google Maps formatter
  • proximity search views plugin
  • Views style plugin "Geolocation - Common Map" to display multiple results on the same map.
  • Views AirBnB like formatter (new in version 8.x-1.8).
  • Lots of tests

The template geolocation-formatter-geolocation-latlng.html.twig receives latitude and logitude as separate variables. This allows themers to freely style the output.

Example: embed your own Google Map

{% spaceless %}
  <iframe width="600" height="300" frameborder="0" style="border:0" src="{{ lat }}%2C{{ lng }}&key=YOUR_API_KEY"></iframe>
{% endspaceless %}

Google Maps example

Drupal 8 TODOs

Any contribution is welcome: patches, feature request, ...

Drupal 7

  • Plain text (input & output)
  • Google Maps (input & output)
  • Geolocation HTML5 (input & output)
  • Geolocation Proximity for proximity/distance based view results.
  • 7.x-1.x-dev Google Maps Geocoder (backport of Drupal 8 version)
  • 7.x-1.x-dev Template based microdata formatter (backport of Drupal 8 version)

Technical background (Drupal 7/Drupal 8)

At the moment Geolocation stores the following values in the database:

  • lat (latitude),
  • lng (longitude),
  • lat_sin (precalculated latitude sine),
  • lat_cos (precalculated latitude cosine),
  • lng_rad (precalculated radian longitude).

The precalculated values will speed up proximity SQL look ups.

Supporting organizations: 

Project Information