You are here

class openlayers_layer_type in Openlayers 6.2

Same name and namespace in other branches
  1. 7.2 openlayers.module \openlayers_layer_type

We define base classes in the core module. All other parent classes can be autoloaded through ctools.

Hierarchy

Expanded class hierarchy of openlayers_layer_type

3 string references to 'openlayers_layer_type'
hook_openlayers_layer_types in docs/openlayers.api.php
OpenLayers Layer Types
openlayers_views_openlayers_layer_types in modules/openlayers_views/openlayers_views.module
Implementation of hook_openlayers_layer_types()
_openlayers_openlayers_layer_types in includes/openlayers.layer_types.inc
Layer Type Implementation

File

./openlayers.module, line 890
Main OpenLayers API File

View source
class openlayers_layer_type {
  var $options, $map;
  function __construct($layer = array(), $map = array()) {
    foreach (array(
      'name',
      'title',
      'description',
      'data',
      'export_type',
    ) as $k) {
      if (isset($layer->{$k})) {
        $this->{$k} = $layer->{$k};
      }
    }
    if (isset($this->data) && is_array($this->data)) {
      $this->data += $this
        ->options_init();
    }
    $this->map = $map;
  }
  function options_init() {
    return array();
  }
  function options_form() {
    return array();
  }

  /**
   * @return
   *   A version of this layer_type which can be saved,
   *   when attempting to save a modified layer
   */
  function to_record() {
    return array(
      'name' => $this->name,
      'description' => $this->description,
      'title' => $this->title,
      'data' => $this->data,
    );
  }

  /**
   * @return
   *   Success value on saving this layer
   */
  function save() {
    if (!empty($this->name)) {
      $exists = db_result(db_query("SELECT name FROM {openlayers_layers} WHERE name = '%s'", $this->name));

      // If this layer exists, specify that 'name' is
      // the primary key for the layer which will be updated
      return $exists ? drupal_write_record('openlayers_layers', $this
        ->to_record(), 'name') : drupal_write_record('openlayers_layers', $this
        ->to_record());
    }
  }
  function render(&$map) {
  }

}

Members