You are here

public function Leaflet::buildOptionsForm in Leaflet 8

Same name and namespace in other branches
  1. 2.1.x modules/leaflet_views/src/Plugin/views/style/Leaflet.php \Drupal\leaflet_views\Plugin\views\style\Leaflet::buildOptionsForm()
  2. 2.0.x modules/leaflet_views/src/Plugin/views/style/Leaflet.php \Drupal\leaflet_views\Plugin\views\style\Leaflet::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides StylePluginBase::buildOptionsForm

File

modules/leaflet_views/src/Plugin/views/style/Leaflet.php, line 134

Class

Leaflet
Style plugin to render a View output as a Leaflet map.

Namespace

Drupal\leaflet_views\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // Choose a map preset.
  $map_options = [];
  foreach (leaflet_map_get_info() as $key => $map) {
    $map_options[$key] = $map['label'];
  }
  $form['map'] = [
    '#title' => $this
      ->t('Map'),
    '#type' => 'select',
    '#options' => $map_options,
    '#default_value' => $this->options['map'] ?: '',
    '#required' => TRUE,
  ];
  $form['height'] = [
    '#title' => $this
      ->t('Map height'),
    '#type' => 'textfield',
    '#field_suffix' => $this
      ->t('px'),
    '#size' => 4,
    '#default_value' => $this->options['height'],
    '#required' => TRUE,
  ];

  // @todo add note about adding leaflet attachments for data points.
}