function _openlayers_presets_ui_get_projections in Openlayers 6
Sort Projections
Given layers, sort projections out
Parameters
$layers: Array of layers
Return value
Return sorted array
2 calls to _openlayers_presets_ui_get_projections()
- openlayers_presets_ui_presets_manage_add in modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc - Menu Callback for Add Preset
- _openlayers_presets_ui_form_center_map in modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc - Create Centering Map
File
- modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc, line 1005 - This file holds the functions for the openlayers presets ui
Code
function _openlayers_presets_ui_get_projections($layers = array()) {
$all_projections = array();
$projection_layers = array();
// Check $layers
if (!is_array($layers)) {
return $projection_layers;
}
// Go through layers
foreach ($layers as $layer_key => $layer) {
// Check projections
if ($layer['projection']) {
// Go through projections
foreach ($layer['projection'] as $projection) {
if (!array_key_exists($projection, $projection_layers)) {
$projection_layers[$projection] = array();
}
$projection_layers[$projection][] = $layer_key;
}
}
}
// Add any layers that do not have a projection specified to all
foreach ($layers as $layer_key => $layer) {
// Check projections
if (!$layer['projection']) {
// Go through projections
foreach ($projection_layers as $k => $v) {
$projection_layers[$k][] = $layer_key;
}
}
}
// Return array
return $projection_layers;
}