You are here

public function GeometryViewsBoundaryFilter::getAvailableMapCenterOptions in Geolocation Field 8.3

For one MapCenter (i.e. boundary filter), return all options (all filters).

Parameters

mixed $context: Context like field formatter, field widget or view.

Return value

array Available center options indexed by ID.

Overrides ViewsBoundaryFilter::getAvailableMapCenterOptions

File

modules/geolocation_geometry/src/Plugin/geolocation/MapCenter/GeometryViewsBoundaryFilter.php, line 21

Class

GeometryViewsBoundaryFilter
Derive center from boundary filter.

Namespace

Drupal\geolocation_geometry\Plugin\geolocation\MapCenter

Code

public function getAvailableMapCenterOptions($context) {
  $options = [];
  if ($displayHandler = self::getViewsDisplayHandler($context)) {

    /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
    foreach ($displayHandler
      ->getHandlers('filter') as $filter_id => $filter) {
      if ($filter
        ->getPluginId() === 'geolocation_geometry_filter_boundary') {

        // Preserve compatibility to v1.
        $options['boundary_filter_' . $filter_id] = $this
          ->t('Geo Boundary filter') . ' - ' . $filter
          ->adminLabel();
      }
    }
  }
  return $options;
}