openlayers-8.x-4.x-dev/src/Plugin/Layer/Vector/Vector.php

src/Plugin/Layer/Vector/Vector.php
<?php

namespace Drupal\openlayers\Plugin\Layer\Vector;

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

/**
 * Defines the Vector layer for an Openlayers map.
 *
 * @OpenlayersPlugin(
 *   id = "ol_layer_vector",
 *   label = @Translation("Vector"),
 *   description = @Translation("Define a vector layer."),
 *   service = "openlayers.Layer:Vector",
 *   library = "openlayers-plugin-layer-vector",
 *   is_configurable = "true",
 *   type = "layer"
 * )
 */
class Vector extends Layer {

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

    return $summary;
  }
  
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'id' => 'ol_layer_vector',
      'className' => 'ol-vector-layer',
      'test6' => 'ttttttttttt',
    ];
  }

  /**
   * {@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,
    ];
/*
    $form['tipLabel'] = [
      '#type' => 'textfield',
      '#default_value' => $this->configuration['tipLabel'],
      '#title' => t('Tip label'),
      '#description' => t('Text label to use for the button tip.'),
      '#size' => 100,
      '#maxlength' => 100,
      '#required' => FALSE,
    ];
    $form['label'] = [
      '#type' => 'textfield',
      '#default_value' => $this->configuration['label'],
      '#title' => t('Label'),
      '#description' => t('Text label to use for the button.'),
      '#size' => 100,
      '#maxlength' => 100,
      '#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');
/*    
    $this->configuration['collapsible'] = $form_state->getValue('collapsible');
    $this->configuration['collapsed'] = $form_state->getValue('collapsed');
    $this->configuration['tipLabel'] = $form_state->getValue('tipLabel');
    $this->configuration['label'] = $form_state->getValue('label');
    $this->configuration['collapseLabel'] = $form_state->getValue('collapseLabel');
*/
  }

}

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

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