function openlayers_behaviors_process_zoom_to_layer in Openlayers 6
Callback for OpenLayers Behaviors (Zoom to Layer)
Parameters
$behavior: Data about behavior
$map: Map array
Return value
Behavior array
2 string references to 'openlayers_behaviors_process_zoom_to_layer'
- hook_openlayers_behaviors_info in docs/
openlayers.api.php - OpenLayers Behaviors Info
- openlayers_behaviors_openlayers_behaviors_info in modules/
openlayers_behaviors/ openlayers_behaviors.module - Implementation of hook_openlayers_behaviors_info().
File
- modules/
openlayers_behaviors/ includes/ openlayers_behaviors.behaviors.inc, line 21 - This file holds the main Drupal hook functions and private functions for the openlayers_behaviors module.
Code
function openlayers_behaviors_process_zoom_to_layer($behavior, &$map) {
// Check to make sure the layer attribute is properly set.
if ($behavior['layer']) {
// If it's a sting, check to make sure the layer exists.
if (is_string($behavior['layer'])) {
if ($map['layers'][$behavior['layer']]) {
return $behavior;
}
}
// If it's an array, check to make sure all layers exist.
if (is_array($behavior['layer'])) {
$pass = TRUE;
foreach ($behavior['layer'] as $layer) {
if (!$map['layers'][$layer]) {
$pass = FALSE;
}
}
if ($pass) {
return $behavior;
}
}
}
return FALSE;
}