I'm trying to add a layer control for data related to a specific column in my dataset. There are 5 types of it, and I would like people to be able to filter the markers and also see them divided into different colours. There are lots of resources but somehow the examples are either too simple or too complex. My code so far:
it_coords = [41.902782 , 12.496366]
m = folium.Map(location=it_coords, zoom_start=6,tiles='openstreetmap')
cluster = folium.plugins.MarkerCluster(name="Monumenti").add_to(m)
for i in range(0,len(df)):
html=f"""
<h2> {df.iloc[i]['Titolo']}</h2>
"""
iframe = folium.IFrame(html=html, width=200, height=200)
popup = folium.Popup(iframe, max_width=2650)
for grp_name, df_grp in df.groupby('Tipologia personaggio'):
feature_group = folium.FeatureGroup(grp_name)
feature_group.add_to(m)
folium.Marker(
location=[df.iloc[i]['Latitude'], df.iloc[i]['Longitude']],
popup=popup
).add_to(m)
folium.LayerControl().add_to(m)