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

Help switching layers #104

Open
jzadra opened this issue Nov 16, 2021 · 1 comment
Open

Help switching layers #104

jzadra opened this issue Nov 16, 2021 · 1 comment

Comments

@jzadra
Copy link

jzadra commented Nov 16, 2021

Is there any way using EasyButton to switch between layers in the same way that a LayersControl would for baseGroups?

@atstp
Copy link
Contributor

atstp commented Dec 6, 2021

yeah, the second argument to your button's function is the map, so you can interact as you see fit.

Roughly, it would look like this:

L.easyButton( '<span>Swap Layers</span>', function(controlArg, mapArg){
    unwantedLayer.remove();
    wantedLayer.addTo(mapArg);
}).addTo(myMap);

Let me know if you have any other questions

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

2 participants