function _openlayers_upgrade_1xto2x_convert_layers in Openlayers 6.2
Converting layer arrays 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_layers()
- _openlayers_upgrade_1xto2x in ./
openlayers.install - Function to handle upgrading from 1.x to 2.x
File
- ./
openlayers.install, line 342 - This file holds the functions for the installing and enabling of the openlayers module.
Code
function _openlayers_upgrade_1xto2x_convert_layers(&$map = array(), &$ret = array()) {
// Array to associate named layers to 2.x
$layer_convert = array(
'openlayers_default_wms',
'openlayers_layers_nasa_global_mosaic' => '',
'openlayers_layers_nasa_daily_planet' => '',
'openlayers_layers_nasa_global_mosaic' => '',
'openlayers_layers_nasa_daily_planet' => '',
'openlayers_layers_nasa_blue_marble' => '',
'openlayers_layers_open_aerial' => '',
'openlayers_layers_google_street' => 'google_normal',
'openlayers_layers_google_satellite' => 'google_satellite',
'openlayers_layers_google_hybrid' => 'google_hybrid',
'openlayers_layers_google_physical' => 'google_physical',
'openlayers_layers_yahoo_street' => 'yahoo_street',
'openlayers_layers_yahoo_satellite' => 'yahoo_satellite',
'openlayers_layers_yahoo_hybrid' => 'yahoo_hybrid',
'openlayers_layers_virtual_earth_street' => 'virtualearth_street',
'openlayers_layers_virtual_earth_satellite' => 'virtualearth_satellite',
'openlayers_layers_virtual_earth_hybrid' => 'virtualearth_hybrid',
'openlayers_layers_osm_mapnik' => 'osm_mapnik',
'openlayers_layers_osm_tah' => 'osm_tah',
'openlayers_layers_osm_cycle' => 'osm_cycle',
'openlayers_layers_osm_4326_hybrid' => 'osm_4326_hybrid',
'openlayers_layers_cloudmade' => '',
'openlayers_default_wms' => 'wms_default',
);
// Array to associate layer types to 2.x
$layer_type_convert = array(
'WMS' => 'openlayers_layer_type_wms',
'Vector' => '',
// ??
'KML' => 'openlayers_layer_type_kml',
'XYZ' => 'openlayers_layer_type_xyz',
'Google' => 'openlayers_layer_type_google',
'VirtualEarth' => 'openlayers_layer_type_virtualearth',
'Yahoo' => 'openlayers_layer_type_yahoo',
'Cloudmade' => 'openlayers_layer_type_cloudmade',
);
// Check that there are layers
if (isset($map['layers']) && is_array($map['layers'])) {
// Go through layers
foreach ($map['layers'] as $id => $layer) {
// Convert named layers
if (is_string($layer)) {
if (!empty($layer_convert[$layer])) {
unset($map['layers'][$id]);
$map['layers'][$layer_convert[$layer]] = $layer_convert[$layer];
}
// What to do with named layers that dont translate ??
}
elseif (is_array($layer)) {
// Save new layer in DB, then map to preset
}
}
}
// Check default layer
if (!empty($map['default_layer']) && is_string($map['default_layer']) && !empty($layer_convert[$map['default_layer']])) {
$map['default_layer'] = $layer_convert[$map['default_layer']];
// Ensure that layer is in layer array
if (empty($map['layers'][$map['default_layer']])) {
$map['layers'][$map['default_layer']] = $map['default_layer'];
}
}
}