You are here

function openlayers_get_layer_object in Openlayers 6.2

Same name and namespace in other branches
  1. 7.2 openlayers.module \openlayers_get_layer_object()

Get layer object

Parameters

$reset: Boolean whether to reset cache or not

Return value

array array of layer info

3 calls to openlayers_get_layer_object()
openlayers_layers_load in ./openlayers.module
Get all openlayers layers as objects.
openlayers_layer_load in ./openlayers.module
Menu loader for layers. (%openlayers_layer)
openlayers_ui_get_layer_options in modules/openlayers_ui/openlayers_ui.module
Get layer options.

File

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

Code

function openlayers_get_layer_object($layer, $map = array()) {

  // Static cache because this function will possibly be called in big loops
  static $layer_types;
  if (!isset($layer_types)) {
    $layer_types = openlayers_layer_types();
  }
  $layer->title = t($layer->title);
  $layer->description = t($layer->description);

  // Attempt to get ctool class
  // class is renamed klass because of PHP keywords
  if (isset($layer_types[$layer->data['layer_type']]) && ($klass = ctools_plugin_get_class($layer_types[$layer->data['layer_type']], 'layer_type'))) {
    $layer_object = new $klass($layer, $map);
    return $layer_object;
  }
  else {
    watchdog('openlayers', 'Layer !layer_name is unavailable because its
      layer type or the module that provides its layer type is missing', array(
      '!layer_name' => $layer->title,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
}