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 Answer 1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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