You are here

class openlayers_layer_type_xyz in Openlayers 6.2

Same name and namespace in other branches
  1. 7.2 plugins/layer_types/openlayers_layer_type_xyz.inc \openlayers_layer_type_xyz

OpenLayers XYZ Layer Type class

Hierarchy

Expanded class hierarchy of openlayers_layer_type_xyz

4 string references to 'openlayers_layer_type_xyz'
openlayers_layer_type_xyz::options_form in includes/layer_types/xyz.inc
Options form which generates layers
_openlayers_openlayers_layers in includes/openlayers.layers.inc
@file
_openlayers_openlayers_layer_types in includes/openlayers.layer_types.inc
Layer Type Implementation
_openlayers_upgrade_1xto2x_convert_layers in ./openlayers.install
Converting layer arrays for the upgrade from 1.x to 2.x

File

includes/layer_types/xyz.inc, line 12
XYZ Layer Type http://dev.openlayers.org/docs/files/OpenLayers/Layer/XYZ-js.html

View source
class openlayers_layer_type_xyz extends openlayers_layer_type {
  function __construct($layer = array(), $map = array()) {
    parent::__construct($layer, $map);
    if (isset($this->data)) {
      $this->data += $this
        ->options_init();
    }
    else {
      $this->data = $this
        ->options_init();
    }
  }

  /**
   * Provide initial values for options.
   */
  function options_init() {
    return array(
      'serverResolutions' => openlayers_get_resolutions('900913'),
      'maxExtent' => openlayers_get_extent('900913'),
      'layer_handler' => 'xyz',
      'baselayer' => TRUE,
    );
  }

  /**
   * Options form which generates layers
   */
  function options_form() {
    return array(
      'base_url' => array(
        '#type' => 'textfield',
        '#title' => t('Base URL (template)'),
        '#default_value' => isset($this->data['base_url']) ? $this->data['base_url'] : '',
      ),
      'layer_type' => array(
        '#type' => 'hidden',
        '#value' => 'openlayers_layer_type_xyz',
      ),
      'resolutions' => array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#options' => array_combine(array_map('strval', openlayers_get_resolutions('900913')), range(0, 18)),
        '#title' => t('Zoom Level Range'),
        '#default_value' => isset($this->data['resolutions']) ? $this->data['resolutions'] : array_map('strval', openlayers_get_resolutions('900913')),
      ),
      'projection' => array(
        '0' => array(
          '#type' => 'hidden',
          '#value' => '900913',
        ),
      ),
    );
  }

  /**
   * Render.
   */
  function render(&$map) {
    drupal_add_js(drupal_get_path('module', 'openlayers') . '/includes/layer_types/js/xyz.js');
    return $this->options;
  }

}

Members