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
Below is a proposal originating from another thread. Other options can be discussed, but note, there are a lot of things to take into account.
publicinterfaceILayerCollection{voidClear();// Removes all layers for all groupsvoidClear(intgroup);// Removes all layers in a group. No default here. If there is no group argument all layers will be cleared, see Clear()voidAddToTop(ILayerlayer,intgroup=0);voidAddToBottom(ILayerlayer,intgroup=0);voidMoveToTop(ILayerlayerToMove,intgroup=0);voidMoveToBottom(ILayerlayerToMove,intgroup=0);voidMoveUp(ILayerlayerToMove,keepWithinGroup=false);// if it is the top layer in the group it will become the bottom layer in the group above, but not if keepWithinGroup is truevoidMoveDown(ILayerlayerToMove,keepWithinGroup=false);// if it is the bottom layer in the group it will become the top layer in the group above, but not if keepWithinGroup is truevoidInsertAbove(ILayerreferenceLayer,ILayerlayerToInsert);voidInsertBelow(ILayerreferenceLayer,ILayerlayerToInsert);ILayerRemove(ILayerlayer);// Returns the removed layers so that it can be used for moving}
I think, that @pauldendulk proposal is an enhancement of the existing one. With this, you could create groups of layers. E.g. you have on a map the background, the map (tiles) itself and additional layers above the map. If you want layers to stay on top all others, then you have to group them and say, where a new layer should go. You could do this automagical or by hand. Up to now, it isn't possible to move Layers, because it is only a list. They appear in the order, someone added them. If you then add a map later, it is the topmost layer, which hides all others. To bring a special Layer to the top, you have to remove them and readd them again. Each time you do such things, the screen is redrawn. With 5 Layers, you have 6 times to redraw the screen (one clear list and five adds). So the functions to move around layers would be helpful.
The main idea is to add grouping. The layers that are part of the Mapview could be in a group that is on top of the main group that the app developer is using.
I absolutely agree that grouping is a very reasonable idea here. However, I'm not sure if the interface you suggest is suitable, see my comment in #1489 (comment):
However, one disadvantage of the interface proposed in #1491 is that there is no way to restrict access to a specific group ...
Let's say we put the 'user' layers into group 0 and the 'special/internal' layers of the MapView into group 1. Then, how do you prevent a user from adding a layer to group 1 (or group 2)?
Maybe an alternative would be to use a top-level class LayerCollection that would contain one or several LayerGroup objects (ordered in a particular way), which in turn contain an ordered list of layers.
Then you could have one group exposed publicly and keep the other one private ...
Activity
pauldendulk commentedon Feb 15, 2022
Random thoughts:
janusw commentedon Feb 15, 2022
So, there is already a
Mapsui.Layers.LayerCollectionwhich has very similar methods, right?The interface is somewhat different from what you propose, but the functionality is basically the same, right?
So, what exactly do you suggest? Replace this one by the new one? Expand it to include some convenience methods? Or just use it more consequently?
charlenni commentedon Feb 15, 2022
I think, that @pauldendulk proposal is an enhancement of the existing one. With this, you could create groups of layers. E.g. you have on a map the background, the map (tiles) itself and additional layers above the map. If you want layers to stay on top all others, then you have to group them and say, where a new layer should go. You could do this automagical or by hand. Up to now, it isn't possible to move Layers, because it is only a list. They appear in the order, someone added them. If you then add a map later, it is the topmost layer, which hides all others. To bring a special Layer to the top, you have to remove them and readd them again. Each time you do such things, the screen is redrawn. With 5 Layers, you have 6 times to redraw the screen (one clear list and five adds). So the functions to move around layers would be helpful.
janusw commentedon Feb 15, 2022
Ah yeah, thanks for the comment. I see the
grouparguments now (obviously I wasn't looking very closely at the code sample). Makes total sense! 😃pauldendulk commentedon Feb 15, 2022
The main idea is to add grouping. The layers that are part of the Mapview could be in a group that is on top of the main group that the app developer is using.
janusw commentedon Feb 15, 2022
I absolutely agree that grouping is a very reasonable idea here. However, I'm not sure if the interface you suggest is suitable, see my comment in #1489 (comment):
pauldendulk commentedon Oct 25, 2024
This is implemented in this PR. Further modifications should be discussed in a new issue.