function _openlayers_layers_process in Openlayers 6
Same name and namespace in other branches
- 6.2 includes/openlayers.render.inc \_openlayers_layers_process()
- 7.2 includes/openlayers.render.inc \_openlayers_layers_process()
Process Layers
Get full data for any layers and add handlers
Parameters
$layers: Array of layers to process
$map: Map array
Return value
Array of processed layers
1 call to _openlayers_layers_process()
- openlayers_render_map in ./
openlayers.module - Render Map
File
- includes/
openlayers.render.inc, line 22 - This file holds the functions the extra processing of rendering a map
Code
function _openlayers_layers_process($layers = array(), &$map = array()) {
if (!$layers) {
$layers = array();
}
if (!is_array($map)) {
$map = array();
}
$processed = array();
// Get layer info array
$layer_info = openlayers_layers_get_info();
// Check to make sure our default layer is present, if it isn't then add it.
if (!array_key_exists($map['default_layer'], $layers) && $map['default_layer']) {
$layers[$map['default_layer']] = $map['default_layer'];
}
// Go through layers
foreach ($layers as $k => $layer) {
// Check if array, if array, just pass on
if (is_array($layer)) {
$processed[$k] = $layer;
}
else {
// If not array, we want to include the file and call the function
if (($info = $layer_info[$layer]) && is_array($layer_info[$layer])) {
// Check if file exists
if (is_file('./' . $info['file'])) {
require_once './' . $info['file'];
// Check for function
if (function_exists($info['callback'])) {
// Call function and give it the layer name
$result = $info['callback']($layer, $map);
// Check for result
if (isset($result) && is_array($result)) {
$processed[$layer] = $result;
}
}
}
}
}
}
// Add Handlers
$handlers = module_invoke_all('openlayers_layers_handler_info', $map);
// Go through processed
foreach ($processed as $k => $l) {
// Check for handler
if (is_string($handlers[$l['type']]['layer_handler'])) {
$processed[$k]['layer_handler'] = $handlers[$l['type']]['layer_handler'];
// Include JS file if there is one
if (is_string($handlers[$l['type']]['js_file'])) {
drupal_add_js($handlers[$l['type']]['js_file'], 'module');
}
}
}
// Return processed
return $processed;
}