You are here

class openlayers_layer_type_cloudmade in Openlayers 7.2

Same name and namespace in other branches
  1. 6.2 includes/layer_types/cloudmade.inc \openlayers_layer_type_cloudmade

OpenLayers CloudMade Layer Type class

Hierarchy

Expanded class hierarchy of openlayers_layer_type_cloudmade

File

plugins/layer_types/openlayers_layer_type_cloudmade.inc, line 11
OpenLayers CloudMade layer type

View source
class openlayers_layer_type_cloudmade extends openlayers_layer_type {

  /**
   * Provide initial values for options.
   */
  function options_init() {
    return array(
      'layer_handler' => 'cloudmade',
      'key' => variable_get('openlayers_layers_cloudmade_api', ''),
    ) + parent::options_init();
  }

  /**
   * Options form which generates layers
   */
  function options_form($defaults = array()) {
    $warning = !variable_get('openlayers_layers_cloudmade_js', FALSE) || !variable_get('openlayers_layers_cloudmade_api', FALSE) ? array(
      '#value' => t('WARNING: Your CloudMade API key or
          Javascript location is not set. Map including CloudMade layers
          will break until they are set correctly.'),
    ) : NULL;
    return array(
      'styleId' => array(
        '#type' => 'textfield',
        '#title' => t('Style ID'),
        '#description' => t('Enter the numeric Style ID for a <a href="http://maps.cloudmade.com/editor">Map Style</a> from CloudMade. You can usually find the Style ID in the lower right hand corner of each Map Style box.'),
        '#default_value' => isset($this->data['styleId']) ? $this->data['styleId'] : '',
      ),
      $warning,
    );
  }

  /**
   * Layer-type-wide settings form
   */
  function settings_form() {
    return array(
      'openlayers_layers_cloudmade_api' => array(
        '#type' => 'textfield',
        '#title' => t('CloudMade API Key'),
        '#default_value' => variable_get('openlayers_layers_cloudmade_api', ''),
        '#description' => t('<a href="@cloudmade">Get a CloudMade account and API Key</a>', array(
          '@cloudmade' => 'http://cloudmade.com/user/show',
        )),
      ),
      'openlayers_layers_cloudmade_js' => array(
        '#type' => 'textfield',
        '#title' => t('CloudMade Javascript Location'),
        '#default_value' => variable_get('openlayers_layers_cloudmade_js', ''),
        '#description' => t('The Drupal path or full URL to the location of the ' . '<a href="@url">Cloudmade OpenLayers Javascript library</a>', array(
          '@url' => 'http://developers.cloudmade.com/projects/show/openlayers-api',
        )),
      ),
    );
  }

  /**
   * Render.
   */
  function render(&$map) {
    static $cloudmade_maps_included;
    if (!isset($cloudmade_maps_included)) {
      drupal_add_js(drupal_get_path('module', 'openlayers') . '/plugins/layer_types/openlayers_layer_type_cloudmade.js');
      $path = variable_get('openlayers_layers_cloudmade_js', '');
      if (valid_url($path, TRUE)) {

        // TODO: could be collapsed, removing the if-else
        drupal_add_js($path, 'external');
      }
      else {
        drupal_add_js($path);
      }
      $cloudmade_maps_included = TRUE;
    }
  }

}

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::options_form_validate function Validate the options_form(). 11
openlayers_layer_type::__construct function Set configuration and store map.
openlayers_layer_type_cloudmade::options_form function Options form which generates layers Overrides openlayers_layer_type::options_form
openlayers_layer_type_cloudmade::options_init function Provide initial values for options. Overrides openlayers_layer_type::options_init
openlayers_layer_type_cloudmade::render function Render. Overrides openlayers_layer_type::render
openlayers_layer_type_cloudmade::settings_form function Layer-type-wide settings form Overrides openlayers_layer_type::settings_form