You are here

function openlayers_layer_type_kml::options_form in Openlayers 7.2

Same name and namespace in other branches
  1. 6.2 includes/layer_types/kml.inc \openlayers_layer_type_kml::options_form()

Options form which generates layers

Overrides openlayers_layer_type::options_form

File

plugins/layer_types/openlayers_layer_type_kml.inc, line 37
KML Layer Type

Class

openlayers_layer_type_kml
OpenLayers KML Layer Type class

Code

function options_form($defaults = array()) {
  return array(
    'method' => array(
      '#type' => 'select',
      '#options' => array(
        '' => 'Choose the method',
        'url' => 'Provides an URL',
        'file' => 'Upload a file',
        'raw' => 'Write KML',
      ),
      '#default_value' => isset($this->data['method']) ? $this->data['method'] : '',
    ),
    'url' => array(
      '#type' => 'textfield',
      '#title' => t('URL'),
      '#description' => t('The URL of the KML file.'),
      '#maxlength' => 2083,
      '#default_value' => isset($this->data['url']) ? $this->data['url'] : '',
      '#states' => array(
        'visible' => array(
          ':input[name="openlayers_layer_type_kml[method]"]' => array(
            'value' => 'url',
          ),
        ),
      ),
    ),
    'file' => array(
      '#name' => 'files[imagelayer]',
      '#type' => 'managed_file',
      '#title' => t('KML file'),
      '#default_value' => isset($this->data['file']) ? $this->data['file'] : '',
      '#upload_location' => 'public://',
      '#upload_validators' => array(
        'file_validate_extensions' => array(
          'kml',
        ),
      ),
      '#states' => array(
        'visible' => array(
          ':input[name="openlayers_layer_type_kml[method]"]' => array(
            'value' => 'file',
          ),
        ),
      ),
    ),
    'raw' => array(
      '#type' => 'textarea',
      '#title' => t('Raw KML'),
      '#description' => t('Copy your KML in this textarea. Don\'t forget that this is not intented to have a big length.'),
      '#default_value' => isset($this->data['raw']) ? $this->data['raw'] : '',
      '#states' => array(
        'visible' => array(
          ':input[name="openlayers_layer_type_kml[method]"]' => array(
            'value' => 'raw',
          ),
        ),
      ),
    ),
    'formatOptions' => array(
      'extractStyles' => array(
        '#type' => 'checkbox',
        '#title' => t('Extract Styles'),
        '#description' => t('Extract styles from KML.'),
        '#default_value' => isset($this->data['formatOptions']['extractStyles']) ? $this->data['formatOptions']['extractStyles'] : TRUE,
      ),
      'extractTracks' => array(
        '#type' => 'checkbox',
        '#title' => t('Extract Tracks'),
        '#description' => t('Extract tracks from KML.'),
        '#default_value' => isset($this->data['formatOptions']['extractTracks']) ? $this->data['formatOptions']['extractTracks'] : TRUE,
      ),
      'extractAttributes' => array(
        '#type' => 'checkbox',
        '#title' => t('Extract Attributes'),
        '#description' => t('Extract attributes from KML.'),
        '#default_value' => isset($this->data['formatOptions']['extractAttributes']) ? $this->data['formatOptions']['extractAttributes'] : TRUE,
      ),
    ),
    'attribution' => array(
      '#type' => 'textfield',
      '#title' => t('Attribution'),
      '#default_value' => isset($this->data['attribution']) ? $this->data['attribution'] : '',
    ),
  );
}