In this recipe, we will create an interactive map using UTFGrid. The benefit of using UTFGrid instead of markers is that UTFGrids can handle a lot more data than it is possible to handle otherwise.
If your map needs to interact with several thousands of bits of data, it is no longer viable to fetch this data in a single pass, then cache it in the browser, and generate markers from it. It's inefficient performance-wise, but luckily, UTFGrid comes to the rescue in such extreme cases.
The steps to be performed are as follows:
Create a map with TileMill. Use the templates section of TileMill to add interactivity to the map.
Upload the map to Mapbox (or host it in your own server).
L.mapbox.gridLayerand pass the Map ID.
Then use the
map.on('click', onClickCallback)handler to generate a popup when a user clicks on a