You are here

public function Location::getAvailableMapCenterOptions in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/geolocation/MapCenter/Location.php \Drupal\geolocation\Plugin\geolocation\MapCenter\Location::getAvailableMapCenterOptions()

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 MapCenterBase::getAvailableMapCenterOptions

File

src/Plugin/geolocation/MapCenter/Location.php, line 69

Class

Location
Location based map center.

Namespace

Drupal\geolocation\Plugin\geolocation\MapCenter

Code

public function getAvailableMapCenterOptions($context = NULL) {
  $options = [];

  /** @var \Drupal\geolocation\LocationInterface $location_plugin */
  foreach ($this->locationManager
    ->getDefinitions() as $location_plugin_id => $location_plugin_definition) {

    /** @var \Drupal\geolocation\LocationInterface $location_plugin */
    $location_plugin = $this->locationManager
      ->createInstance($location_plugin_id);
    foreach ($location_plugin
      ->getAvailableLocationOptions($context) as $location_id => $location_label) {
      $options[$location_id] = $location_label;
    }
  }
  return $options;
}