How do I change the default state (off or on) of a toggle menu in Mapbox GL JS? The code that I'm using came from another question on this site Mapbox GLJS - group layers
Answer
Since the layers in the map are all off by default, you can change this:
link.className = 'active';
to:
link.className = '';
If you want the state of your toggle to reflect what's in the map, it's a bit more code and you need to wait for the map to load before building the toggles. Here's a modified example that does this:
No comments:
Post a Comment