You are here

class openlayers_layer_type_maptiler in Openlayers 7.2

Same name and namespace in other branches
  1. 6.2 includes/layer_types/maptiler.inc \openlayers_layer_type_maptiler

OpenLayers MapTiler Layer Type class

Hierarchy

Expanded class hierarchy of openlayers_layer_type_maptiler

File

plugins/layer_types/openlayers_layer_type_maptiler.inc, line 10
TileWarper Layer Type

View source
class openlayers_layer_type_maptiler extends openlayers_layer_type {

  /**
   * Provide initial values for options.
   */
  function options_init() {
    return array(
      'type' => 'png',
      'layer_handler' => 'maptiler',
      'zoomOffset' => 0,
    ) + parent::options_init();
  }

  /**
   * Options form which generates layers
   */
  function options_form($defaults = array()) {
    return array(
      'base_url' => array(
        '#type' => 'textfield',
        '#title' => t('Base URL'),
        '#default_value' => isset($this->data['base_url']) ? $this->data['base_url'] : '',
      ),
      'type' => array(
        '#type' => 'select',
        '#options' => array(
          'jpg' => 'JPG',
          'png' => 'PNG',
        ),
        '#default_value' => isset($this->data['type']) ? $this->data['type'] : 'png',
      ),
      'resolutions' => array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#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']) ? $this->data['resolutions'] : array_map('strval', openlayers_get_resolutions('EPSG:900913')),
      ),
      'zoomOffset' => array(
        '#type' => 'textfield',
        '#title' => t('Zoom offset'),
        '#default_value' => isset($this->data['zoomOffset']) ? $this->data['zoomOffset'] : 0,
        '#description' => t('If your cache has more zoom levels than you want to provide access to with this layer, supply a zoomOffset.  This zoom offset is added to the current map zoom level to determine the level for a requested tile.  For example, if you supply a zoomOffset of 3, when the map is at the zoom 0, tiles will be requested from level 3 of your cache.  Default is 0 (assumes cache level and map zoom are equivalent).  Using zoomOffset is an alternative to setting serverResolutions if you only want to expose a subset of the server resolutions.'),
      ),
    );
  }
  function options_form_submit($form, &$form_state) {
    parent::options_form_submit($form, $form_state);
    $form_state['values']['data']['base_url'] = explode("\n", $form_state['values']['data']['base_url']);
    $form_state['values']['data']['resolutions'] = array_map('floatval', array_values($form_state['values']['data']['resolutions']));
    $form_state['values']['data']['zoomOffset'] = intval($form_state['values']['data']['zoomOffset'], 10);
  }

  /**
   * Render.
   */
  function render(&$map) {
    drupal_add_js(drupal_get_path('module', 'openlayers') . '/plugins/layer_types/openlayers_layer_type_maptiler.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_validate function Validate the options_form(). 11
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_maptiler::options_form function Options form which generates layers Overrides openlayers_layer_type::options_form
openlayers_layer_type_maptiler::options_form_submit function Submit the options_form(). Overrides openlayers_layer_type::options_form_submit
openlayers_layer_type_maptiler::options_init function Provide initial values for options. Overrides openlayers_layer_type::options_init
openlayers_layer_type_maptiler::render function Render. Overrides openlayers_layer_type::render