You are here

class openlayers_layer_type_xyz in Openlayers 7.2

Same name and namespace in other branches
  1. 6.2 includes/layer_types/xyz.inc \openlayers_layer_type_xyz

OpenLayers XYZ Layer Type class

Hierarchy

Expanded class hierarchy of openlayers_layer_type_xyz

1 string reference to 'openlayers_layer_type_xyz'
_openlayers_openlayers_layers in includes/openlayers.layers.inc
Internal callback Helper function to return default layers.

File

plugins/layer_types/openlayers_layer_type_xyz.inc, line 11
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 {

  /**
   * Provide initial values for options.
   */
  function options_init() {
    return array(
      'layer_handler' => 'xyz',
      'sphericalMercator' => TRUE,
      'wrapDateLine' => FALSE,
      'zoomOffset' => 0,
      'resolutions' => array_slice(openlayers_get_resolutions('EPSG:900913'), 0, 18),
    ) + parent::options_init();
  }

  /**
   * Options form which generates layers
   */
  function options_form($defaults = array()) {
    return array(
      'url' => array(
        '#type' => 'textarea',
        '#title' => t('Base URL (template)'),
        '#default_value' => !empty($this->data['url']) ? implode("\n", (array) $this->data['url']) : '',
        '#maxlength' => 2083,
        '#description' => t('This is the base URL template for the XYZ layer.  It should be something similar to <em>http://example.com/tiles/1.0.0/layer_name/${z}/${x}/${y}.png</em>.'),
      ),
      'serverResolutions' => array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#description' => t('Only set this if you need to request very specific resolutions from the server.'),
        '#options' => array_combine(array_map('strval', openlayers_get_resolutions('EPSG:900913')), range(0, 21)),
        '#title' => t('Server Zoom Level Range'),
        '#default_value' => isset($this->data['serverResolutions']) ? array_map('strval', $this->data['serverResolutions']) : array(),
      ),
      'resolutions' => array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#description' => t('Only set this if you need a very specific resolution.'),
        '#options' => array_combine(array_map('strval', openlayers_get_resolutions('EPSG:900913')), range(0, 21)),
        '#title' => t('Zoom Level Range'),
        '#default_value' => isset($this->data['resolutions']) ? array_map('strval', $this->data['resolutions']) : array(),
      ),
      'zoomOffset' => array(
        '#type' => 'select',
        '#description' => t('Zoom offset.'),
        '#options' => array_combine(range(0, 21), range(0, 21)),
        '#title' => t('Zoom offset'),
        '#default_value' => isset($this->data['zoomOffset']) ? $this->data['zoomOffset'] : array(),
      ),
      'wrapDateLine' => array(
        '#type' => 'checkbox',
        '#title' => t('Wrap Date Line'),
        '#default_value' => isset($this->data['wrapDateLine']) ? $this->data['wrapDateLine'] : FALSE,
        '#description' => t('This allows the user to continually pan left and right as the tiles will repeat themselves.  Note that this option is known to not work well with the 2.10 OL library.'),
      ),
    );
  }
  function options_form_validate($form, &$form_state) {
    $form_state['data']['url'] = explode("\n", $form_state['data']['url']);
    $form_state['data']['serverResolutions'] = array_map('floatval', array_values($form_state['data']['serverResolutions']));
    $form_state['data']['resolutions'] = array_map('floatval', array_values($form_state['data']['resolutions']));
    $form_state['data']['zoomOffset'] = (int) $form_state['data']['zoomOffset'];
  }

  /**
   * Render.
   */
  function render(&$map) {
    drupal_add_js(drupal_get_path('module', 'openlayers') . '/plugins/layer_types/openlayers_layer_type_xyz.js');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
openlayers_layer_type::$data public property Stores the options for this layer.
openlayers_layer_type::$map public property Stores the current map.
openlayers_layer_type::getProjections public function
openlayers_layer_type::options_form_submit function Submit the options_form(). 6
openlayers_layer_type::settings_form function Options form to configure layer-type-wide options. 3
openlayers_layer_type::__construct function Set configuration and store map.
openlayers_layer_type_xyz::options_form function Options form which generates layers Overrides openlayers_layer_type::options_form
openlayers_layer_type_xyz::options_form_validate function Validate the options_form(). Overrides openlayers_layer_type::options_form_validate
openlayers_layer_type_xyz::options_init function Provide initial values for options. Overrides openlayers_layer_type::options_init
openlayers_layer_type_xyz::render function Render. Overrides openlayers_layer_type::render