You are here

private function GeofieldMapFieldTrait::setMapZoomAndPanElement in Geofield Map 8

Same name and namespace in other branches
  1. 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapZoomAndPanElement()

Set Map Zoom and Pan Element.

Parameters

array $settings: The Form Settings.

array $default_settings: The default_settings.

array $elements: The Form element to alter.

1 call to GeofieldMapFieldTrait::setMapZoomAndPanElement()
GeofieldMapFieldTrait::generateGmapSettingsForm in src/GeofieldMapFieldTrait.php
Generate the Google Map Settings Form.

File

src/GeofieldMapFieldTrait.php, line 528

Class

GeofieldMapFieldTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\geofield_map

Code

private function setMapZoomAndPanElement(array $settings, array $default_settings, array &$elements) {
  $elements['map_zoom_and_pan'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Map Zoom and Pan'),
  ];
  $elements['map_zoom_and_pan']['zoom'] = [
    'initial' => [
      '#type' => 'number',
      '#min' => $settings['map_zoom_and_pan']['zoom']['min'],
      '#max' => $settings['map_zoom_and_pan']['zoom']['max'],
      '#title' => $this
        ->t('Start Zoom'),
      '#default_value' => $settings['map_zoom_and_pan']['zoom']['initial'],
      '#description' => $this
        ->t('The Initial Zoom level of the Google Map.'),
      '#element_validate' => [
        [
          get_class($this),
          'zoomLevelValidate',
        ],
      ],
    ],
    'force' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Force the Start Zoom'),
      '#description' => $this
        ->t('In case of multiple GeoMarkers, the Map will naturally focus zoom on the input Geofields bounds.<br>This option will instead force the Map Zoom on the input Start Zoom value'),
      '#default_value' => $settings['map_zoom_and_pan']['zoom']['force'],
      '#return_value' => 1,
    ],
    'min' => [
      '#type' => 'number',
      '#min' => isset($default_settings['map_zoom_and_pan']['default']) ? $default_settings['map_zoom_and_pan']['default']['zoom']['min'] : $default_settings['map_zoom_and_pan']['zoom']['min'],
      '#max' => $settings['map_zoom_and_pan']['zoom']['max'],
      '#title' => $this
        ->t('Min Zoom Level'),
      '#default_value' => $settings['map_zoom_and_pan']['zoom']['min'],
      '#description' => $this
        ->t('The Minimum Zoom level for the Map.'),
    ],
    'max' => [
      '#type' => 'number',
      '#min' => $settings['map_zoom_and_pan']['zoom']['min'],
      '#max' => isset($default_settings['map_zoom_and_pan']['default']) ? $default_settings['map_zoom_and_pan']['default']['zoom']['max'] : $default_settings['map_zoom_and_pan']['zoom']['max'],
      '#title' => $this
        ->t('Max Zoom Level'),
      '#default_value' => $settings['map_zoom_and_pan']['zoom']['max'],
      '#description' => $this
        ->t('The Maximum Zoom level for the Map.'),
      '#element_validate' => [
        [
          get_class($this),
          'maxZoomLevelValidate',
        ],
      ],
    ],
  ];
  $elements['map_zoom_and_pan']['scrollwheel'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Scrollwheel'),
    '#description' => $this
      ->t('Enable scrollwheel zooming'),
    '#default_value' => $settings['map_zoom_and_pan']['scrollwheel'],
    '#return_value' => 1,
  ];
  $elements['map_zoom_and_pan']['draggable'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Draggable'),
    '#description' => $this
      ->t('Enable dragging/panning on the map'),
    '#default_value' => $settings['map_zoom_and_pan']['draggable'],
    '#return_value' => 1,
  ];
  $elements['map_zoom_and_pan']['map_reset'] = [
    '#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'),
    '#default_value' => isset($settings['map_zoom_and_pan']['map_reset']) ? $settings['map_zoom_and_pan']['map_reset'] : FALSE,
    '#return_value' => 1,
  ];
}