(New) Drupal 8 Geofield Proximity View (Field, Filter and Sort) Handlers System

Created on 10 November 2018, over 5 years ago
Updated 5 April 2024, 3 months ago

As a follow up of the requests raised from this original issue: Re-implement the Views proximity filter/field for Drupal 8,
the attached patch implements a new solid, scalable and extensible Geofield Proximity System, composed by the following plugins handlers:

  • View Proximity Filter (\Drupal\geofield\Plugin\views\filter\GeofieldProximityFilter);
  • View Proximity Field (\Drupal\geofield\Plugin\views\field\GeofieldProximityField);
  • View Proximity Sort (\Drupal\geofield\Plugin\views\sort\GeofieldProximitySort);

These Views Proximity Handlers mainly extend the correspondent Numeric Views handlers, and are able to calculate the distance between every view results’ geofield and a geo origin, whose definition is driven by a dependent scalable Geofield Proximity Sources plugins sub-system.

As a whole, this Geofield Proximity View Handlers System is fully Drupal 8 plugins system compliant, so that is should be considered extensible/scalable with new specialized plugins by everybody.

The patch here attached allows the following main initial functionalities:

View Proximity Filter
The user is able to:

  • add a geofield proximity filter (or more than one);
  • define a criteria of selection based on a specific operator, a Distance or a Distance Interval (min and max value), and different distance Units (km, meters, yards, miles, etc);
  • choose the Origin definition among the Proximity Sources options. At the moment the following have been defined:
  • Manual Origin (Default): manual input of Latitude and Longitude;
  • Geofield Fixed Origin (for Demo purposes)
  • make the geofield proximity filter exposed, exposing both the Distance and the Origin specific input;
  • add (or hide) the specific description defined for the Proximity Source in the exposed form;
  • enjoy exposed geofield proximity filter functionalities also with Ajax, if enabled;

View Proximity Field
The user is able to:

  • add a geofield proximity fileld (or more than one), able to calculate and render a Distance (with specific Units) for every results’ geofield and a specific Origin definition, among one of the followings:
  • Manual Origin (Default): manual input of Latitude and Longitude;
  • Origin from Proximity Filter: dynamic and automatic input of the Origin coordinates from an existing Proximity Filter Origin (this will dinamically change accordingly to the Proximity Filter Origin, also when it is exposed);
  • define the specific format of the Proximity field, as a normal Numeric field;
  • enjoy the dynamic change of the geofield proximity field with Ajax, if enabled;
  • make it click - sortable in the Table format;

View Proximity Sort
The user is able to:

  • add a Geofield Proximity Sort, that adds a Sort Order based on Proximity Distance (with specific Units) calculated for every results’ geofield from a specific Origin definition, among one of the followings:
  • Manual Origin (Default): manual input of Latitude and Longitude;
  • Origin from Proximity Filter: dynamic / automatic input of the Origin coordinates from an existing Proximity Filter Origin (this will dinamically change accordingly to the Proximity Filter Origin, also when it is exposed);
  • define the specific order (Desc or Asc) for the Proximity sort;
📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇹Italy itamair

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇰Denmark ressa Copenhagen

    Amazing feature, thanks for creating it @itamair! I wanted to add a proximity search ("Show shops close to you") and wasn't sure if I needed another module ... but when I looked under "Filter criteria" in my View, there it was:

    "Geofield Proximity"

    This is a killer feature, which in my opinion deserves a prominent place on the https://www.drupal.org/project/geofield → project description. Both to alert users scanning the module description that the feature exists, but also to allow it to get found via search engines.

    Maybe add a new section, right below "Formatters (Data Output)"?

    Proximity Views filter (Field, Filter and Sort)

    Supports proximity filter in Views, to limit data by proximity, calculate and sort by distance, and much more. Supports client Location through the browser HTML5 Geolocation API. For more, see 📌 (New) Drupal 8 Geofield Proximity View (Field, Filter and Sort) Handlers System Fixed .

    Or maybe even better, perhaps the features listed on 📌 (New) Drupal 8 Geofield Proximity View (Field, Filter and Sort) Handlers System Fixed could get copied into a dedicated Proximity search page in the documentation?

Production build 0.69.0 2024