You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: layers are ordered based on the order in which they are added to the map. We can't always control this order.
In farmOS, a lot of the layers are being added via farmOS-map behaviors that are stored in JS files added to the page via drupal_add_js in PHP. These are added by various modules, depending on what is enabled on the farmOS system. We could use the module weight mechanisms that Drupal provides to control this, but in the interest of making things easier for non-Drupal devs who want to work with the maps, having a baked-in mechanism in farmOS-map would be preferrable.
Upstream, OpenLayers has an example for ordering the layer weights with CSS z-index (https://openlayers.org/en/latest/examples/layer-z-index.html) - but this approach won't work for us because we also want the layers to be ordered correctly in the Layerswitcher control, which is based on the actual map layer order. So ideally we would be able to manage the map layer order directly, and let everything bubble up from there.
Perhaps we can offer some kind of weight option to addLayer() in the farmOS-map library that allows specifying a weight for ordering purposes. Higher weights would be "heavier" and would cause the layer to sink lower in the list. The trick will be reordering layers as they are added, and maintaining the weight state associated with each.
Another consideration: layer groups. We need to be able to order layer groups at the very least, but maybe also layers within the groups.
The text was updated successfully, but these errors were encountered:
After giving this some more thought, I think the issue is actually with the ordering of behaviors in window.farmOS.map.behaviors - NOT necessarily the ordering of layers and groups themselves. If I can better control the order in which behaviors are attached to a map, then I can control the order of layers. So that might be a better approach.
Problem: layers are ordered based on the order in which they are added to the map. We can't always control this order.
In farmOS, a lot of the layers are being added via farmOS-map behaviors that are stored in JS files added to the page via
drupal_add_js
in PHP. These are added by various modules, depending on what is enabled on the farmOS system. We could use the module weight mechanisms that Drupal provides to control this, but in the interest of making things easier for non-Drupal devs who want to work with the maps, having a baked-in mechanism in farmOS-map would be preferrable.Upstream, OpenLayers has an example for ordering the layer weights with CSS
z-index
(https://openlayers.org/en/latest/examples/layer-z-index.html) - but this approach won't work for us because we also want the layers to be ordered correctly in the Layerswitcher control, which is based on the actual map layer order. So ideally we would be able to manage the map layer order directly, and let everything bubble up from there.Perhaps we can offer some kind of
weight
option toaddLayer()
in the farmOS-map library that allows specifying a weight for ordering purposes. Higher weights would be "heavier" and would cause the layer to sink lower in the list. The trick will be reordering layers as they are added, and maintaining theweight
state associated with each.Another consideration: layer groups. We need to be able to order layer groups at the very least, but maybe also layers within the groups.
The text was updated successfully, but these errors were encountered: