How can I get all layers from a style that uses multiple sources? #4734
Unanswered
bsherman101
asked this question in
Q&A
Replies: 1 comment
-
Custom layers are not included in the StyleSpecification produced by getStyle(). However, all layers' IDs, including those of custom layers, and regardless of source, should be included in getLayersOrder(). I have an application that has that same use case, and I'm using that function to get each layer, including its custom ones. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am working on a style editor and it works great when I have a style file with a single source such as an openmaptiles mbtile source.
When I call map.getStyle().layers I get all the layers I expect.
However I have a style that has an openmaptiles source as its first source and then a Contours Vector tile source and a raster hillshade source.
When I call the same map.getStyle().layers I only get the layers for the first source, the openmaptile's layers. My layers that define the contours and hillshade are never returned.
If I use map.style._layers I get an object that has all the layers but it comes back as a StyleLayer array which I cant do much with. I also know Im not supposed to use _layers as its private.
I also thought of trying to use map.style.getLayersOrder() and then call map.style.getLayer(id) but it too does not provide the id's of the layers that use the other sources.
So, does anyone know how I can easily get the layers of everything in my style file so I can edit their properties?
Thanks for your help and insight.
Beta Was this translation helpful? Give feedback.
All reactions