'is it possible to programatically "uncheck" showed layers in a folium map after rendering the map? (for performance reasons)

I've run into an interesting problem with folium (python 3.95, folium 0.12.1.post1)

The following code renders the map very fast:

import folium

m = folium.Map(location=[35.11567262307692,-89.97423444615382], zoom_start=12, tiles='Stamen Terrain')

for i in range(200):
    feature_group = folium.FeatureGroup(i, show=True)
    feature_group.add_to(m)

folium.LayerControl().add_to(m)
m

However, if show is set to False, it takes much longer to render.

import folium

m = folium.Map(location=[35.11567262307692,-89.97423444615382], zoom_start=12, tiles='Stamen Terrain')

for i in range(200):
    feature_group = folium.FeatureGroup(i, show=False)
    feature_group.add_to(m)

folium.LayerControl().add_to(m)
m

The problem is, I don't want these layers shown by default. So I'm wondering if there's a way to render the map, and then automatically uncheck the layers.

Failing that, are there any other ways to deal with this performance issue?

Thanks very much for any guidance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source