openlayers-8.x-4.x-dev/src/Plugin/Interaction/DragRotate/DragRotate.php

src/Plugin/Interaction/DragRotate/DragRotate.php
<?php

namespace Drupal\openlayers\Plugin\Interaction\DragRotate;

use Drupal\Core\Form\FormStateInterface;
use Drupal\openlayers\Types\Interaction;

/**
 * FIX - Insert short comment here.
 *
 * @OpenlayersPlugin(
 *   id = "ol_interaction_dragrotate",
 *   label = @Translation("Drag Rotate"),
 *   description = @Translation("Allows the user to rotate the map by clicking and dragging
 *    on the map when the [ALT] and [SHIFT] keys are held down. This
 *    interaction is only supported for mouse devices."),
 *   service = "openlayers.Interaction:DragRotate",
 *   library = "openlayers-plugin-interaction-dragrotate",
 *   is_configurable = "true",
 *   type = "interaction"
 * )
 */
class DragRotate extends Interaction {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'decay' => -0.002,
      'minVelocity' => 0.02,
      'delay' => 200,
    ];
  }

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

    $form['decay'] = array(
      '#type' => 'textfield',
      '#title' => t('Decay'),
//      '#default_value' => $this->getOption('decay', -0.005),
      '#default_value' => $this->configuration['decay'],
      '#description' => t('Rate of decay (must be negative).'),
    );
    $form['minVelocity'] = array(
      '#type' => 'textfield',
      '#title' => t('Minimum velocity'),
//      '#default_value' => $this->getOption('minVelocity', 0.05),
      '#default_value' => $this->configuration['minVelocity'],
      '#description' => t('Minimum velocity (pixels/millisecond).'),
    );
    $form['delay'] = array(
      '#type' => 'textfield',
      '#title' => t('Delay'),
//      '#default_value' => $this->getOption('delay', 100),
      '#default_value' => $this->configuration['delay'],
      '#description' => t('Delay to consider to calculate the kinetic.'),
    );
    
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function XXvalidateConfigurationForm(array &$form, FormStateInterface $form_state) {
    if (!$form_state->isValueEmpty('bgcolor') && !Color::validateHex($form_state->getValue('bgcolor'))) {
      $form_state->setErrorByName('bgcolor', $this->t('Background color must be a hexadecimal color value.'));
    }
  }

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

    parent::submitConfigurationForm($form, $form_state);

    $this->configuration['decay'] = $form_state->getValue('decay');
    $this->configuration['minVelocity'] = $form_state->getValue('minVelocity');
    $this->configuration['delay'] = $form_state->getValue('delay');
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc