function _openlayers_layers_process in Openlayers 7.2
Same name and namespace in other branches
- 6.2 includes/openlayers.render.inc \_openlayers_layers_process()
- 6 includes/openlayers.render.inc \_openlayers_layers_process()
Initialize the layer array into an indexed array of layer objects
Parameters
$layers: Array of layers to process
$map: Map array
Return value
$layer_data Array of initialized layer objects
1 call to _openlayers_layers_process()
- openlayers_build_map in ./
openlayers.module - Prepare a map for rendering.
File
- includes/
openlayers.render.inc, line 19 - Processing functions for layers and behaviors
Code
function _openlayers_layers_process($layers = array(), &$map = array()) {
$layer_data = array();
// Load Layers and assign weights
foreach ($layers as $key => $layer) {
if ($layer_object = openlayers_layer_load($layer)) {
$layers[$key] = $layer_object;
if (!empty($map['layer_weight'][$key])) {
$layers[$key]->weight = $map['layer_weight'][$key];
}
else {
$layers[$key]->weight = 0;
}
}
else {
unset($layers[$key]);
}
}
// Sort layers
usort($layers, '_openlayers_layers_process_sort');
// Process into array-based layer data for the map
foreach ($layers as $type => $layer_object) {
if (is_object($layer_object)) {
$layer_object
->render($map);
$layer_object->data['title'] = $layer_object->title;
$layer_object->data['weight'] = $layer_object->weight;
$layer_data[$layer_object->name] = $layer_object->data;
}
}
return $layer_data;
}