0

Is there a way in the free CartoDB to set the layer selector so that you can only select 1 layer at a time? When one layer is selected, deselect all other layers.

1

There is currently no way to do that in that actual editor, however it is possible using CartoDB.js.

There are multiple ways to do this with CartoDB.js, take a look at the following two examples:

http://bl.ocks.org/oriolbx/14786cdd2dca51f4ec9c

http://bl.ocks.org/oriolbx/688c63b865e7045e9f90

The first one hides the other layers and only allows one to be visible at a time, however, it is very easy to modify the second one (using the CartoDB.js API methods .hide() and .show()) to get the functionality you want.

Check out the CartoDB.js documentation for more info on the .hide() and .show() methods.

One more thing, the second example uses named maps, which only apply to private data sets, so just use it as a guide for how it uses the .toggle() method to hide and show layers.

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.