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;