function openlayers_behaviors_process_zoom_to_feature in Openlayers 6
Callback for OpenLayers Behaviors (Zoom to Feature)
Parameters
$behavior: Data about behavior
$map: Map array
Return value
Behavior array
1 string reference to 'openlayers_behaviors_process_zoom_to_feature'
- 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 55 - This file holds the main Drupal hook functions and private functions for the openlayers_behaviors module.
Code
function openlayers_behaviors_process_zoom_to_feature($behavior, &$map) {
// Check to make sure the layer and feature attribute is properly set.
if ($behavior['layer'] && $behavior['feature']) {
// Check to make sure the layer is a string and exists.
if (is_string($behavior['layer']) && $map['layers'][$behavior['layer']]) {
// If it's a sting, check to make sure the feature exists.
if (is_string($behavior['feature'])) {
if ($map['layers'][$behavior['layer']]['features'][$behavior['feature']]) {
return $behavior;
}
}
// If it's an array, check to make sure all features exist.
if (is_array($behavior['feature'])) {
$pass = TRUE;
foreach ($behavior['feature'] as $feature) {
if (!$map['layers'][$behavior['layer']]['features'][$feature]) {
$pass = FALSE;
}
}
if ($pass) {
return $behavior;
}
}
}
}
return FALSE;
}