You are here

private function IpGeoLocPluginStyleLeaflet::addMoreMapOptions in IP Geolocation Views & Maps 8

Form part definition.

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

File

src/Plugin/views/style/IpGeoLocPluginStyleLeaflet.php, line 978

Class

IpGeoLocPluginStyleLeaflet
Views Style plugin extension for Leaflet (if enabled).

Namespace

Drupal\ip_geoloc\Plugin\views\style

Code

private function addMoreMapOptions(&$form, &$weight) {
  $selected_map = $this
    ->pluginStyleLeafletMapGetInfo($this->options['map']);
  $zoom_top = 21;
  if (isset($selected_map['settings']['maxZoom'])) {
    $zoom_top = $selected_map['settings']['maxZoom'];
  }
  $form['map_options_leaflet'] = [
    '#title' => $this
      ->t('More map options'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    // Or: empty($this->options['map_options_leaflet']['zoom']) ?
    '#collapsed' => TRUE,
    '#weight' => $weight++,
  ];
  $form['map_options_leaflet']['maxzoom'] = [
    '#title' => $this
      ->t('Maximum zoom level (0..@zoomtop)', [
      '@zoomtop' => $zoom_top,
    ]),
    '#type' => 'textfield',
    '#size' => 2,
    '#default_value' => $this->options['map_options_leaflet']['maxzoom'],
    '#description' => $this
      ->t('Note that not all maps support all zoom levels.'),
  ];
  $initial_zoom_max = $zoom_top;
  if (is_numeric($this->options['map_options_leaflet']['maxzoom'])) {
    $initial_zoom_max = min($zoom_top, $this->options['map_options_leaflet']['maxzoom']);
  }
  $form['map_options_leaflet']['zoom'] = [
    '#title' => $this
      ->t('Initial zoom level (0..@maxzoom)', [
      '@maxzoom' => $initial_zoom_max,
    ]),
    '#type' => 'textfield',
    '#size' => 2,
    '#default_value' => $this->options['map_options_leaflet']['zoom'],
    '#description' => $this
      ->t('Does not apply to auto-box centering except when only one or no markers are shown.'),
  ];
  $form['map_options_leaflet']['zoom_on_click'] = [
    '#title' => $this
      ->t('Zoom-on-click zoom level (1..@maxzoom)', [
      '@maxzoom' => $zoom_top,
    ]),
    '#type' => 'textfield',
    '#size' => 2,
    '#default_value' => $this->options['map_options_leaflet']['zoom_on_click'],
    '#description' => $this
      ->t('Level to zoom to when a marker is clicked. Leave blank to disable this feature.'),
  ];
  $form['map_options_leaflet']['center_lat'] = [
    '#title' => $this
      ->t('Latitude of initial center of map'),
    '#type' => 'textfield',
    '#size' => 6,
    '#default_value' => $this->options['map_options_leaflet']['center_lat'],
    '#description' => $this
      ->t('If both latitude and longitude are filled out, these override any centering option until the visitor changes their location.'),
  ];
  $form['map_options_leaflet']['center_lon'] = [
    '#title' => $this
      ->t('Longitude of initial center of map'),
    '#type' => 'textfield',
    '#size' => 6,
    '#default_value' => $this->options['map_options_leaflet']['center_lon'],
    '#description' => $this
      ->t('If both latitude and longitude are filled out, these override any centering option until the visitor changes their location.'),
  ];
  $form['map_options_leaflet']['scrollwheelzoom'] = [
    '#title' => $this
      ->t('Enable scroll wheel zoom'),
    '#type' => 'select',
    '#default_value' => $this->options['map_options_leaflet']['scrollwheelzoom'],
    '#options' => [
      TRUE => $this
        ->t('Yes'),
      FALSE => $this
        ->t('No'),
    ],
  ];
  $form['map_options_leaflet']['dragging'] = [
    '#title' => $this
      ->t('Dragging/Panning of the map'),
    '#type' => 'select',
    '#default_value' => $this->options['map_options_leaflet']['dragging'],
    '#options' => [
      TRUE => $this
        ->t('Yes'),
      FALSE => $this
        ->t('No'),
    ],
  ];
  $form['map_options_leaflet']['separator'] = [
    '#title' => $this
      ->t('Separator used in marker balloons'),
    '#type' => 'textfield',
    '#size' => 10,
    '#default_value' => $this->options['map_options_leaflet']['separator'],
    '#description' => $this
      ->t('You may use most HTML tags.'),
  ];
}