Togglers
Controls that enable and disable certain effects on the map.
Last updated
Was this helpful?
Controls that enable and disable certain effects on the map.
Last updated
Was this helpful?
Quickly change the map from a top-down view to an angled view to leverage 3D layouts.
Adds an area for users to turn off and on different layers on your map, as defined in your Mapbox Studio Style or in your Custom Style JSON. .
In the left-hand side text area, you can enter layers on each line that you want to turn off and on when the user toggles them. You can add multiple layers to each line by separating them using commas, such as
Make sure these layers correspond correctly to the layer names you've given in Mapbox Studio -- otherwise your map will have an error!
On the right hand side, add the text that you want to show for each of the toggles.
Choose the Checkbox Type, which can be switches, checkboxes, or radio buttons. Radio buttons mean that only a single set of layers can be shown at once. If you select this, make sure that only one of your layers is visible on the map load, otherwise the control may turn layers off by accident.
To set this up, go to Controls when creating your map. Make sure you are not using a Google Map, and turn on the Style Control. Then, enter in each Style URL or Custom JSON in the left-side textbox, and titles on the right-hand side. Each entry should be on a different line so that the plugin can associate the correct style with the correct title.
Put controls into a toggleable menu in order to preserve space on the map. Controls you've added will be visible here and you can reorder them as desired.
This adds an area on the map with a list of styles that you choose that users can toggle between. .
If you are using a Custom JSON, make sure to use a tool like to remove all line breaks from your JSON before pasting it in. A couple examples of this are shown below!