I am making a choropleth map in Folium which displays data for certain age brackets. I would like to add a double ended slider letting users select the bottom and top of the age range to view. The data is from the census which has 14 different age brackets. Thus the slider should have discretized stopping points corresponding to the age ranges specified by the Census data. Something like this: https://digital-geography.com/filter-leaflet-maps-slider/

The only way I know how to do this in Folium would be to make each possible pair of ages its own layer and then switch between them in the layer menu. However this would increase the amount of data I would have by a factor of 98, and the map is already 270 KB with a single layer. So it would be an almost 20 MB webpage if I do it this way! Plus I would not have a slider.

Is there some other way of doing my desired functionality with an actual slider instead of the layer controls and without having to store such a large HTML page?

1 Answer 1


Plotting Layers and Titles in Folium

I add an answer in case someone needed it in the future.

import folium
folium.TileLayer('Stamen Terrain').add_to(m2)
folium.TileLayer('Stamen Toner').add_to(m2)
folium.TileLayer('Stamen Water Color').add_to(m2)

  • 1
    This in no way, shape, or form answers the OP's question. This just sets a bunch of base maps. Oddly enough, this was the answer from a YouTube video that asked this same question. Wasn't the answer on YouTube, not the answer here.
    – Will
    Commented Sep 9, 2022 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.