Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify layer order/weight #56

Closed
mstenta opened this issue Dec 5, 2019 · 2 comments
Closed

Specify layer order/weight #56

mstenta opened this issue Dec 5, 2019 · 2 comments
Labels
enhancement New feature or request wontfix This will not be worked on
Milestone

Comments

@mstenta
Copy link
Member

mstenta commented Dec 5, 2019

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.

@mstenta mstenta added this to the v1.0.0 milestone Dec 5, 2019
@mstenta mstenta added the enhancement New feature or request label Jan 20, 2020
@mstenta
Copy link
Member Author

mstenta commented Feb 3, 2020

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.

@mstenta mstenta added the wontfix This will not be worked on label Feb 3, 2020
@mstenta
Copy link
Member Author

mstenta commented Feb 3, 2020

ordering of behaviors in window.farmOS.map.behaviors

This is possible now via 0179f0f

Closing this as "won't fix".

@mstenta mstenta closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Development

No branches or pull requests

1 participant