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

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

namespace Drupal\openlayers\Plugin\Layer\Tile;

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

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

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

    return $summary;
  }
  
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
/*
      'className' => 'ol-tile-layer',
      'test4' => 'qqqqqqqqqq',
*/
      'id' => 'ol_layer_tile',
/*
      'test5' => 'ssssssssss',
      'entityId' => '?? 1',
      'base' => '?? 2',
      'title' => '?? 3',
      'visible' => '?? 4',
*/
/*
      'tipLabel' => 'Full Screen',
      'label' => 'a1',     
*/
    ];
  }

  /**
   * {@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');
/*    
    $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