You can specify both the interactive content of a layer and its
legend (in HTML) within TileMill, and use these both either
through a TileStream Hosting embed, or with the Wax library if you're coding the
With the documentation I've seen, it only explains how to do
interactivity in terms of a scroll-over (like the "Geography Class"
example in TileMill) or clicking on something on the map. I'd like
to be able to add interactivity with the legend, to be able to
select different layers to show. Or select different variables
(i.e. population density, literacy rates, etc.).
I'm also relatively new to coding, which is why this is a little
Support Staff4 Posted by Will White on 16 Sep, 2011 01:44 PM
It sounds like what you're looking for is a layer switcher. We
don't provide any layer switcher behaviors out of the box because
it's relatively easy to create a custom one using HTML and
Here are some guiding steps:
Export your layers from TileMill as individual MBTiles and load
them into TileStream for hosting on the web.
1) So in order to set up the layer switcher using HTML and
into MapBox hosting separately? So if I have 5 layers, would that
count as 5 different maps on MapBox hosting? (I suppose this
question is also tied to hosting, but related)
2) Any other tips on setting up a layer switcher using HTML and
3) Is there any way to use Wax/Modest Maps not on a custom HTML
page? I know a bit of coding and am learning more, but am not
looking to create an HTML page from scratch. Thoughts?
Support Staff7 Posted by Will White on 08 Oct, 2011 05:08 PM
So in order to set up the layer switcher using HTML and
into MapBox hosting separately?
That's correct, but MapBox Hosting now allows all accounts to
have unlimited maps. There are just limits on how much storage you
use with your account.
Any other tips on setting up a layer switcher using HTML and
A good example site to refer to is http://data.nai.org.af/. Each time
you click on a year in the timeline, the map changes using
Is there any way to use Wax/Modest Maps not on a custom HTML
You can use Wax & Modest Maps on any web page that allows
We have the embed builder on MapBox hosting, but it is tailored
for a specific use that we found to be most common for people. It
does not allow you to build a layer switcher, because that involves
tighter integration with an application and thus ends up requiring
custom code anyway.
So with the violence against journalists in Afghanistan example,
how can you create the two sets of layer switchers - one that shows
the years and one that shows different background information
(Journalists, Media Outlets, etc.)?
Support Staff13 Posted by Will White on 10 Oct, 2011 04:19 PM
The violence against journalists site is using some more advanced parts
of the API. MapBox Hosting can composite multiple tilesets
together before sending them to the browser based on the layer URL.
The buttons are simply manipulating the layer URL.
Compare the URL of the tiles after clicking the buttons.
Initially, the URL for a tile looks like this:
Support Staff15 Posted by Will White on 10 Oct, 2011 06:17 PM
Awesome, glad it's useful. It's also worth mentioning that the
Violence Against Journalists site is using legacy API endpoints, so
the URLs in my post above are using an old format. You should refer
to the API
documentation for information about using the newest version of