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

Sort key not working across different layer types #13013

Open
idanlo opened this issue Dec 17, 2023 · 4 comments
Open

Sort key not working across different layer types #13013

idanlo opened this issue Dec 17, 2023 · 4 comments

Comments

@idanlo
Copy link

idanlo commented Dec 17, 2023

If you have 2 layers of different types, the sort keys won't be taken into consideration, meaning that fill layers could be rendered on top of a symbol even though they have sort keys that suggest that the symbol should be on top.

Steps to Trigger Behavior

  1. Create a symbol layer with a single item, have a sort key of 100
  2. Create a fill layer of a single polygon that contains the symbol location, make it have a sort key of 90
  3. The fill layer will be above the symbol

Expected Behavior

Sort key will be calculated among all layer types and be global

Actual Behavior

Sort keys only work on same layer types

@mourner
Copy link
Member

mourner commented Dec 19, 2023

-sort-key properties only reorder features within a layer — they are not designed to control rendering order across layers. We might need to clarify this in the docs, but that's how they work, and it's technically not possible to implement them differently.

@idanlo
Copy link
Author

idanlo commented Dec 19, 2023

-sort-key properties only reorder features within a layer — they are not designed to control rendering order across layers. We might need to clarify this in the docs, but that's how they work, and it's technically not possible to implement them differently.

So there's no way for me to declare a layer that is above other layers? If my app loads rasters dynamically then the raster that is loaded latest is above all my other layers (symbols, fills etc)

@mourner
Copy link
Member

mourner commented Dec 19, 2023

@idanlo when adding a layer with map.addLayer, there's a beforeId parameter you can use to specify where to place that layer in relation to other layers.

@idanlo
Copy link
Author

idanlo commented Dec 20, 2023

@idanlo when adding a layer with map.addLayer, there's a beforeId parameter you can use to specify where to place that layer in relation to other layers.

This accepts a single string. is it possible for a layer to be before 2 other layers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants