0

Using Mapbox's 'Toggle Layer' example, how would I load the map with the "contours" and "museums" layers turned off?

I want the layers to be turned "off" by default and have the user turn "on" the layers.

I've tried replacing

link.className = 'active';

With

link.className = '';

Per this question, but still doesn't work.

1

Additionally to what you've done replacing

link.className = 'active'; with link.className = '';,

you need to set

'visibility': 'none'

for both layers when adding them to the map:

Example: http://jsbin.com/vosenopedu/edit?html,output

  • Fantastic, thanks so much for your help! This worked perfectly! – pac_co Sep 13 '18 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.