You are here

public function GoogleMaps::getSettingsForm in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php \Drupal\geolocation_google_maps\Plugin\geolocation\MapProvider\GoogleMaps::getSettingsForm()

Provide a generic map settings form array.

Parameters

array $settings: The current map settings.

array $parents: Form parents.

Return value

array A form array to be integrated in whatever.

Overrides GoogleMapsProviderBase::getSettingsForm

File

modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php, line 115

Class

GoogleMaps
Provides Google Maps.

Namespace

Drupal\geolocation_google_maps\Plugin\geolocation\MapProvider

Code

public function getSettingsForm(array $settings, array $parents = []) {
  $settings = $this
    ->getSettings($settings);
  $parents_string = '';
  if ($parents) {
    $parents_string = implode('][', $parents) . '][';
  }
  $form = parent::getSettingsForm($settings, $parents);
  $form['zoom']['#min'] = static::$minZoomLevel;
  $form['zoom']['#max'] = static::$maxZoomLevel;
  $form['maxZoom'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'number',
    '#min' => static::$minZoomLevel,
    '#max' => static::$maxZoomLevel,
    '#title' => $this
      ->t('Max Zoom level'),
    '#description' => $this
      ->t('The maximum zoom level of the map. If omitted, or set to null, the default maximum zoom from the current map type is used instead.'),
    '#default_value' => $settings['maxZoom'],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\Number',
        'preRenderNumber',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  $form['minZoom'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'number',
    '#min' => static::$minZoomLevel,
    '#max' => static::$maxZoomLevel,
    '#title' => $this
      ->t('Min Zoom level'),
    '#description' => $this
      ->t('The minimum zoom level of the map. If omitted, or set to null, the default minimum zoom from the current map type is used instead.'),
    '#default_value' => $settings['minZoom'],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\Number',
        'preRenderNumber',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  $form['behavior_settings'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Behavior'),
  ];
  $form['gestureHandling'] = [
    '#group' => $parents_string . 'behavior_settings',
    '#type' => 'select',
    '#title' => $this
      ->t('Gesture Handling'),
    '#default_value' => $settings['gestureHandling'],
    '#description' => $this
      ->t('Define how to handle interactions with map on mobile. Read the <a href=":introduction">introduction</a> for handling or the <a href=":details">details</a>, <i>available as of v3.27 / Nov. 2016</i>.', [
      ':introduction' => 'https://googlegeodevelopers.blogspot.de/2016/11/smart-scrolling-comes-to-mobile-web-maps.html',
      ':details' => 'https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapOptions',
    ]),
    '#options' => [
      'auto' => $this
        ->t('auto (default)'),
      'cooperative' => $this
        ->t('cooperative'),
      'greedy' => $this
        ->t('greedy'),
      'none' => $this
        ->t('none'),
    ],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\Select',
        'processSelect',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  return $form;
}