Use the top right Layers Control to dynamically add / remove Layer Groups from the map. Notice that child markers are actually added to / removed from the Marker Cluster Group!
This is the standard Leaflet Layers Control.
Note: it is normal that the computed clusters depend on the order of insertion. This is a result of Leaflet.markercluster algorithm.
This example is directly adapted from Leaflet.markercluster
demo page.
The only difference is that markers are added to 4 different subGroup
's which are bound to the MarkerClusterGroup, instead of markers being directly added to the MCG.
Leaflet | Leaflet.markercluster | Leaflet.FeatureGroup.SubGroup |
---|---|---|
|
|
|
Note: local version is available only in local development and if dist files have been built.