Skip to main content
100%

Layer selector example | CartoDB.js

✓ Published0🌍 Public
Aandrewxhill
Last edited Jan 29, 2015
Created on Jan 29, 2015

This example shows an interactive map with a layer selector that lets users toggle between two data categories, Sunday and Monday, or view all data at once. The map is built with CartoDB.js, using the `cartodb.createVis` API to load a visualization from a hosted CartoDB account. A custom HTML list serves as the selector, and clicking an item triggers JavaScript that calls `layers.getSubLayer().show()` or `.hide()` on the appropriate sublayers. The code also uses the `cartodb.SQL` API, though only for setup, and relies on jQuery for DOM event handling.

AI-generated description

Similar vizzes