You are here

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

Form part definition.

1 call to IpGeoLocPluginStyleLeaflet::addMapAndHeight()
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 304

Class

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

Namespace

Drupal\ip_geoloc\Plugin\views\style

Code

private function addMapAndHeight(&$form, &$weight) {
  $maps = [];
  foreach ($this
    ->pluginStyleLeafletMapGetInfo() as $key => $map) {
    $maps[$key] = $map['label'];
  }
  $form['map'] = [
    '#title' => $this
      ->t('Map'),
    '#type' => 'select',
    '#options' => $maps,
    '#default_value' => $this->options['map'],
    '#required' => TRUE,
    '#weight' => $weight++,
  ];
  $desc1 = $this
    ->t('Examples: <em>250</em> or <em>50em</em> or <em>40vh</em> (percentage of viewport height).');
  $desc2 = $this
    ->t('If left blank, the height defaults to 300 pixels. The width of the map will extend to its bounding container.');
  $desc3 = $this
    ->t('You may enter <em>&lt;none></em>. If you do, then the height attribute must be set through Javascript or CSS elsewhere or the map will not display. CSS example: <em>.ip-geoloc-map .leaflet-container { height: 150px; }</em>');
  $form['map_height'] = [
    '#title' => $this
      ->t('Map height'),
    '#type' => 'textfield',
    '#size' => 7,
    '#default_value' => $this->options['map_height'],
    '#description' => $desc1 . '<br/>' . $desc2 . '<br/>' . $desc3,
    '#weight' => $weight++,
  ];
}