Geolocation Field | Drupal 8 Project | Drupal 8

Geolocation Field | Drupal 8 Project

Project Name : Geolocation Field project Link : Geolocation Field
Created : 2015-10-14
Last Update : 2018-01-13
Current Version : 8.x-2.0-beta1
Download Geolocation Field 8.x-2.0-beta1 Version From : Download

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 tests
  • 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
  • DEV 8.x-1.x: Views style plugin "Geolocation - Common Map" to display multiple results on the same map. Please share your ideas or follow up patches.
    #2604128: Geolocation Views style - Google Common Map for multiple results

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

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.