You are here

ZoomSlider.php in Openlayers 8.4

File

src/Plugin/OpenlayersControl/ZoomSlider.php
View source
<?php

namespace Drupal\openlayers\Plugin\OpenlayersControl;

use Drupal\Component\Utility\Color;
use Drupal\Component\Utility\Rectangle;
use Drupal\Core\Form\FormStateInterface;
use Drupal\openlayers\OpenlayersConfigurablePluginBase;

/**
 * Defines the Zoom Slider control for an Openlayers map.
 *
 * @OpenlayersControl(
 *   id = "ol_control_zoomslider",
 *   label = @Translation("Zoom slider"),
 *   description = @Translation("Define a zoom slider control."),
 *   type = "control",
 *   ol_id = "ZoomSlider"
 * )
 */
class ZoomSlider extends OpenlayersConfigurablePluginBase {

  /**
   * {@inheritdoc}
   */
  public function getSummary() {
    $summary = [
      '#theme' => 'openlayers_control_summary',
      '#data' => $this->configuration,
    ];
    $summary += parent::getSummary();
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'className' => 'ol-zoomslider',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['className'] = [
      '#type' => 'textfield',
      '#default_value' => $this->configuration['className'],
      '#title' => t('Class name'),
      '#description' => t('CSS class name.'),
      '#size' => 50,
      '#maxlength' => 50,
      '#required' => FALSE,
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    $this->configuration['className'] = $form_state
      ->getValue('className');
  }

}

Classes

Namesort descending Description
ZoomSlider Defines the Zoom Slider control for an Openlayers map.