openlayers_layer_type_osm

OpenLayers OSM Layer Type class

Hierarchy

Functions & methods

NameDescription
openlayers_layer_type::save
openlayers_layer_type::to_record
openlayers_layer_type_osm::options_formOptions form which generates layers Overrides openlayers_layer_type::options_form
openlayers_layer_type_osm::options_initProvide initial values for options. Overrides openlayers_layer_type::options_init
openlayers_layer_type_osm::renderRender. Overrides openlayers_layer_type::render
openlayers_layer_type_osm::__construct Overrides openlayers_layer_type::__construct

includes/layer_types/osm.inc, line 12

View code
<?php
class openlayers_layer_type_osm 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'), 
      'projection' => array('900913'), 
      'layer_handler' => 'xyz', 
      'layer_type' => 'osm', 
      'type' => 'png', 
      'baselayer' => TRUE,
    );
  }

  /**
   * Options form which generates layers
   */
  function options_form() {
    return array(
      'base_url' => array(
        '#type' => 'textfield', 
        '#title' => t('Base URL'), 
        '#default_value' => isset($this->data['base_url']) ?
          $this->data['base_url'] : '',
      ), 
      'layer_type' => array(
        '#type' => 'hidden', 
        '#value' => 'openlayers_layer_type_osm',
      ), 
      'type' => array(
        '#type' => 'select', 
        '#title' => t('File Format'), 
        '#options' => array(
          'png' => 'png', 
          'jpg' => 'jpg',
        ), 
        '#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('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')),
      ),
    );
  }

  /**
   * Render.
   */
  function render(&$map) {
    return $this->options;
  }
}
?>