Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/user_guide/plugins/marker_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```