You are here

function _openlayers_upgrade_1xto2x_convert_behaviors in Openlayers 6.2

Converting behaviors for the upgrade from 1.x to 2.x

Parameters

$map: Reference to map array

$ret: Reference to return array

1 call to _openlayers_upgrade_1xto2x_convert_behaviors()
_openlayers_upgrade_1xto2x in ./openlayers.install
Function to handle upgrading from 1.x to 2.x

File

./openlayers.install, line 422
This file holds the functions for the installing and enabling of the openlayers module.

Code

function _openlayers_upgrade_1xto2x_convert_behaviors(&$map = array(), &$ret = array()) {

  // Control behavior conversion array
  $control_convert = array(
    'LayerSwitcher' => 'openlayers_behavior_layerswitcher',
    'Navigation' => 'openlayers_behavior_navigation',
    'PanZoomBar' => 'openlayers_behavior_panzoombar',
    'MousePosition' => 'openlayers_behavior_mouseposition',
    'Attribution' => 'openlayers_behavior_attribution',
    'KeyboardDefaults' => 'openlayers_behavior_keyboarddefaults',
    'Permalink' => 'openlayers_behavior_permalink',
    'ScaleLine' => 'openlayers_behavior_scaleline',
    'ZoomBox' => 'openlayers_behavior_zoombox',
    'ZoomToMaxExtent' => 'openlayers_behavior_zoomtomaxextent',
  );

  // Convert controls
  if (isset($map['controls']) && is_array($map['controls'])) {
    foreach ($map['controls'] as $control => $enabled) {
      if ($enabled && !empty($control_convert[$control])) {
        $map['behaviors'][$control_convert[$control]] = array();
      }

      // Get rid of controls array
      unset($map['controls']);
    }
  }

  // Go through behaviors
  if (isset($map['behaviors']) && is_array($map['behaviors'])) {
    foreach ($map['behaviors'] as $id => $behavior) {

      // Full screen
      if ($behavior['type'] == 'openlayers_behaviors_fullscreen') {
        $map['behaviors']['openlayers_behavior_fullscreen'] = array();
        unset($map['behaviors'][$id]);
      }

      // Zoom to Layer
      if ($behavior['type'] == 'openlayers_behaviors_zoom_to_layer' && !empty($behavior['layer'])) {
        $map['behaviors']['openlayers_behaviors_zoomtolayer'] = array(
          'zoomtolayer' => $behavior['layer'],
        );
        unset($map['beahviors'][$id]);
      }

      // Cluster
      // Zoom to Feature
      // Tooltip
      // Popup
      // Draw Features
      // Declutter
    }
  }
}