From 5858fa6e3881d19a441469c865ca11fd7c7b3fd6 Mon Sep 17 00:00:00 2001 From: Muhammad Hasnain Afkar Date: Sun, 29 Nov 2026 10:35:08 +0500 Subject: [PATCH] Document category toggles in a shared FastMarkerCluster map Added instructions for toggling categories in a shared cluster using FeatureGroupSubGroup with FastMarkerCluster. --- docs/user_guide/plugins/marker_cluster.md | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/user_guide/plugins/marker_cluster.md b/docs/user_guide/plugins/marker_cluster.md index 41d29030e6..76b323df3c 100644 --- a/docs/user_guide/plugins/marker_cluster.md +++ b/docs/user_guide/plugins/marker_cluster.md @@ -146,3 +146,30 @@ FastMarkerCluster(data=list(zip(lats, lons)), callback=callback).add_to(m) m ``` + +### Toggle categories in a shared cluster + +Use a `FeatureGroupSubGroup` for each category and add its coordinates with +`FastMarkerCluster`. The layer control toggles categories independently. +Nearby points from all visible categories contribute to the same cluster count. + +```{code-cell} ipython3 +from folium.plugins import FastMarkerCluster, FeatureGroupSubGroup, MarkerCluster + +m = folium.Map(location=[33.69, 73.05], zoom_start=12) +cluster = MarkerCluster(control=False).add_to(m) + +sites = { + "2G": [[33.686, 73.049], [33.690, 73.051]], + "3G": [[33.689, 73.051]], + "4G": [[33.691, 73.052], [33.692, 73.053]], + "5G": [[33.693, 73.054]], +} + +for technology, locations in sites.items(): + group = FeatureGroupSubGroup(cluster, name=technology).add_to(m) + FastMarkerCluster(locations).add_to(group) + +folium.LayerControl(collapsed=False).add_to(m) +m +```