You are here

protected function CommonMap::getMapUpdateOptions in Geolocation Field 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/style/CommonMap.php \Drupal\geolocation\Plugin\views\style\CommonMap::getMapUpdateOptions()

Map update option handling.

Dynamic map and client location and potentially others update the view by information determined on the client site. They may want to update the view result as well. So we need to provide the possible ways to do that.

Return value

array The determined options.

1 call to CommonMap::getMapUpdateOptions()
CommonMap::buildOptionsForm in src/Plugin/views/style/CommonMap.php
Provide a form to edit options for this plugin.

File

src/Plugin/views/style/CommonMap.php, line 45

Class

CommonMap
Allow to display several field items on a common map.

Namespace

Drupal\geolocation\Plugin\views\style

Code

protected function getMapUpdateOptions() {
  $options = [
    'boundary_filters' => [],
    'boundary_filters_exposed' => [],
    'map_update_options' => [],
  ];
  $filters = $this->displayHandler
    ->getOption('filters');
  foreach ($filters as $filter_name => $filter) {
    if (empty($filter['plugin_id'])) {
      continue;
    }

    /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter_handler */
    $filter_handler = $this->displayHandler
      ->getHandler('filter', $filter_name);
    switch ($filter['plugin_id']) {
      case 'geolocation_filter_boundary':
        if ($filter_handler
          ->isExposed()) {
          $options['boundary_filters_exposed'][$filter_name] = $filter_handler;
        }
        break;
    }
  }
  foreach ($options['boundary_filters_exposed'] as $filter_name => $filter_handler) {
    $options['map_update_options']['boundary_filter_' . $filter_name] = $this
      ->t('Boundary Filter') . ' - ' . $filter_handler
      ->adminLabel();
  }
  return $options;
}