function openlayers_get_layer_object in Openlayers 7.2
Same name and namespace in other branches
- 6.2 openlayers.module \openlayers_get_layer_object()
Get layer object
Return value
openlayers_layer_type|FALSE 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 388 - Main OpenLayers API File
Code
function openlayers_get_layer_object($layer, $map = array()) {
ctools_include('plugins');
// 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
if (isset($layer_types[$layer->data['layer_type']]) && ($class = ctools_plugin_get_class($layer_types[$layer->data['layer_type']], 'layer_type'))) {
$layer_object = new $class($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;
}
}