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

Adding multiple style layers #111

Open
superchad opened this issue Nov 11, 2019 · 1 comment
Open

Adding multiple style layers #111

superchad opened this issue Nov 11, 2019 · 1 comment
Assignees

Comments

@superchad
Copy link

superchad commented Nov 11, 2019

Hello,

We would like to be able to add two style layers to the map. An imagery style that sits below our leaflet data, and a labels style that sits on top of the imagery and data. We have not succeeded at getting this to work. Here is a simple example of what we tried:

https://jsfiddle.net/4j9ghubc/

This only shows the labels. We would like to see the imagery behind the transparent parts of the labels.

Please let us know if you need more example or clarification.

Thanks!

@webberig
Copy link

Leaflet allows you to control this by using "panes". Depending on the situation you can create your own "custom pane" and define its z-index. Check out this article:
https://leafletjs.com/examples/map-panes/

I created an updated (working) version of the jsfiddle:
https://jsfiddle.net/3hcgp6at/2/

map.createPane('labels');
map.getPane('labels').style.zIndex = 650;
map.getPane('labels').style.pointerEvents = 'none';

//add the labels to the labels pane
var gl_labels = new L.MapboxGL({
    accessToken: 'pk.eyJ1Ijoic2VtY29nIiwiYSI6ImlvNEFUcmMifQ.VmDLZZG7l6syscFzkBs5eg',
    style: 'mapbox://styles/semcog/cje93r8vr0flv2sqsyzi99oib',
    pane: 'labels'
}).addTo(map);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants