-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Design proposal: Allow to add layers of type "slot" to facilitate toggling of layers #591
Comments
Assuming I'm serializing the style to an object and then applying this object using seStyle to the map, how would this work? Would I still be able to toggle the same layers? |
Well, it's one of the pending questions in my maplibre-gl-js implementation. Let's decide on the expected behiviour, I would try it and tell if it's easily achievable with these style-spec rules. 1st of all, what should be in the serialized style? Example solution: Does it look good? |
One of the powerful things of the style spec and the style.json is that in most cases you can represent the current state in the style.json. If we are keen on linking between slots and layers we should save it somehow in the exported json and therefore change the spec a bit more, otherwise it's only in memory and considered problematic from my perspective. Also note, that adding these slots layres, without linking it to layers, allows external code to do the manipulation of bulk editing etc so the APIs above are nice-to-have I guess. I also tend to think that adding an invisible circle layer can do the same as this slot concept and maybe its redundant. That's my 2 cents I guess... |
Thanks for detailed response. |
I honestly don't know. It makes sense to add a "placeholder" layer that is not rendered, but the value of it is very limited. |
Thanks for opening this issue @sbachinin. For clarification, can you maybe post an example style.json with the new slot property? |
Thanks for the example. If the main purpose of slots is to improve convenience when manipulating layers in MapLibre GL JS' API, then I would suggest that we create some new methods in MapLibre GL JS instead that work with layer prefixes. For example for visibility, we could do this: map.setLayoutPropertyByIdPrefix('buildings_', 'visibility', 'none') which would act on all layers that have an id starting with |
Just wanted to check in and see if there is any movement or updates on this proposal. The ability to add empty / placeholder layers for client-side customization is something we'd like to support, so happy to help out in any way if we can. |
I think that you can achieve it now using the existing APIs, can't you? |
What would be the preferred approach, creating a layer with an empty layout? For our purposes, it would be good to have a specific layer |
You could add specific layers with an id that start with "placeholder" for example. |
Design Proposal: Allow to add layers of type 'slot'
Motivation
Motivated by a recent discussion in maplibre-gl-js and my own hard experience with toggling.
Proposed Change
User should be able to add layers of
{type: slot}
and no other properties exceptid
.My idea is that slots can be a convenient way to toggle layers, especially groups of layers.
Users will populate (or clear) the slots via a method called something like
populateSlot
.This is what I'm already trying to implement for maplibre-gl-js, and it turns out fairly simple.
See rationale and comparison to mapbox slots in this PR
Migration Plan and Compatibility
This change is meant to introduce only new functionality, no breaking changes.
Rejected Alternatives
Slots can be designed in various ways. Mapbox implementation is quite different from the idea that I suggest here, read about it in the PR mentioned above.
In my implementation when you add "normal" layers to a slot, you do it in a batch, and these "normal" layers themselves have no knowledge of that.
In contrast, mapbox allows to specify a "slot" property on a "normal" layer object, pointing to a slot in which to put this layer.
So in mapbox approach each layer decides in which slot to go.
My idea is different. Based on my experience, it seems more likely that you have a coherent group of layers, such as "all about contours". And you populate a slot at once by calling
populateSlot
, providing an array of contour layers.Then for example you can call
populateSlot
with an empty array, thus emptying the slot.This approach in my opinion is simple and clean. It will give a user less opportunity of creating a mess in layers' order. (And order is the main problem that is ultimately addressed here).
The text was updated successfully, but these errors were encountered: