Ensure that the "base layers" group is always at the bottom of farm map layers.
This commit is contained in:
parent
41831de8c4
commit
04ced2c76b
|
@ -33,7 +33,6 @@ function farm_area_default_openlayers_maps() {
|
|||
'renderer' => 'canvas',
|
||||
'layers' => array(
|
||||
0 => 'farm_area_layer_group',
|
||||
1 => 'farm_map_layer_group',
|
||||
),
|
||||
'controls' => array(
|
||||
0 => 'openlayers_control_zoom',
|
||||
|
|
|
@ -45,7 +45,6 @@ function farm_log_movement_default_openlayers_maps() {
|
|||
'layers' => array(
|
||||
0 => 'farm_asset_full_layer_' . $key,
|
||||
1 => 'farm_asset_cluster_layer_' . $key,
|
||||
2 => 'farm_map_layer_group',
|
||||
),
|
||||
'controls' => array(
|
||||
0 => 'openlayers_control_zoom',
|
||||
|
|
|
@ -32,7 +32,6 @@ function farm_map_default_openlayers_maps() {
|
|||
),
|
||||
'layers' => array(
|
||||
0 => 'farm_map_geofield_widget_layer_group',
|
||||
1 => 'farm_map_layer_group',
|
||||
),
|
||||
'controls' => array(
|
||||
0 => 'openlayers_control_zoom',
|
||||
|
@ -82,7 +81,6 @@ function farm_map_default_openlayers_maps() {
|
|||
),
|
||||
'layers' => array(
|
||||
0 => 'farm_map_geofield_formatter_layer_group',
|
||||
1 => 'farm_map_layer_group',
|
||||
),
|
||||
'controls' => array(
|
||||
0 => 'openlayers_control_zoom',
|
||||
|
@ -110,3 +108,20 @@ function farm_map_default_openlayers_maps() {
|
|||
|
||||
return $export;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_default_openlayers_maps_alter().
|
||||
*/
|
||||
function farm_map_default_openlayers_maps_alter(&$maps) {
|
||||
|
||||
// Add "base layers" group layer to all farm_* maps. This module also
|
||||
// implements hook_module_implements_alter() to ensure that this function
|
||||
// will run last, so that the "base layers" group is always at the bottom
|
||||
// of the layers array in all maps.
|
||||
// @see farm_map_module_implements_alter()
|
||||
foreach ($maps as &$map) {
|
||||
if (substr($map->machine_name, 0, 5) == 'farm_') {
|
||||
$map->options['layers'][] = 'farm_map_layer_group';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,23 @@ function farm_map_openlayers_object_preprocess_alter(&$build, $context) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function for populating the geometry field of an entity.
|
||||
* Implements hook_module_implements_alter().
|
||||
*/
|
||||
function farm_map_module_implements_alter(&$implementations, $hook) {
|
||||
|
||||
// Ensure that this module's implementation of
|
||||
// hook_default_openlayers_maps_alter() always runs last, so that it can add
|
||||
// the "base layers" group to the bottom of the layers list on all farm maps.
|
||||
// @see farm_map_default_openlayers_maps_alter()
|
||||
if ($hook == 'default_openlayers_maps_alter' && array_key_exists('farm_map', $implementations)) {
|
||||
$group = $implementations['farm_map'];
|
||||
unset($implementations['farm_map']);
|
||||
$implementations['farm_map'] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for popu * Helper function for populating the geometry field of an entity.
|
||||
*
|
||||
* @param Entity $entity
|
||||
* The entity object.
|
||||
|
|
Loading…
Reference in New Issue