You are here

protected function LeafletSettingsElementsTrait::setResetMapControl in Leaflet 2.0.x

Same name and namespace in other branches
  1. 8 src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setResetMapControl()
  2. 2.1.x src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setResetMapControl()

Set Map MarkerCluster Element.

Parameters

array $element: The Form element to alter.

array $settings: The Form Settings.

3 calls to LeafletSettingsElementsTrait::setResetMapControl()
LeafletDefaultFormatter::settingsForm in src/Plugin/Field/FieldFormatter/LeafletDefaultFormatter.php
Returns a form to configure settings for the formatter.
LeafletDefaultWidget::settingsForm in src/Plugin/Field/FieldWidget/LeafletDefaultWidget.php
LeafletMap::buildOptionsForm in modules/leaflet_views/src/Plugin/views/style/LeafletMap.php
Provide a form to edit options for this plugin.

File

src/LeafletSettingsElementsTrait.php, line 826

Class

LeafletSettingsElementsTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\leaflet

Code

protected function setResetMapControl(array &$element, array $settings) {
  $default_settings = $this::getDefaultSettings();
  $element['reset_map'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Reset Map Control'),
  ];
  $element['reset_map']['control'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Map Reset Control'),
    '#description' => $this
      ->t('This will show a "Reset Map" button to reset the Map to its initial center & zoom state<br><b><u>Warning: </u></b>Due to an issue in the Leaflet library (@see https://github.com/Leaflet/Leaflet/issues/6172) the Map Reset control doesn\'t work correctly in Fitting Bounds of coordinates having mixed positive and negative values of latitude &longitudes.<br>In this case the Map will be Reset to the default set Map Center.'),
    '#default_value' => isset($settings['reset_map']['control']) ? $settings['reset_map']['control'] : $default_settings['reset_map']['control'],
  ];
  $element['reset_map']['position'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Position'),
    '#options' => $this->controlPositionsOptions,
    '#default_value' => isset($settings['reset_map']['position']) ? $settings['reset_map']['position'] : $default_settings['reset_map']['position'],
  ];
  if (isset($this->fieldDefinition)) {
    $element['reset_map']['position']['#states'] = [
      'visible' => [
        ':input[name="fields[' . $this->fieldDefinition
          ->getName() . '][settings_edit_form][settings][reset_map][control]"]' => [
          'checked' => TRUE,
        ],
      ],
    ];
  }
  else {
    $element['reset_map']['position']['#states'] = [
      'visible' => [
        ':input[name="style_options[reset_map][control]"]' => [
          'checked' => TRUE,
        ],
      ],
    ];
  }
}