I have some points that I want to be clustered in a L.MarkerClusterGroup, which works well:

var cluster = new L.MarkerClusterGroup(options);
features.foreach(function(feature) {
    var layer = L.marker(feature, {title: feature.name});

And some geofences that that I don't want clustered, in a drawable layer, which also works well:

var easel = L.FeatureGroup().addTo(map);
map.draw = new L.Control.Draw({edit: {featureGroup: easel}});

How can I add the cluster featureGroup to the editable featureGroup, so that the points get clustered and are editable?

I have tried adding the individual feature layers into both feature groups, but then I see both the cluster and all the individual points at the same time. The editing would have to occur only if you've zoomed in far enough to see an individual marker of a cluster.

Ideally, it would be great I could have a parent featureGroup, and have those two featureGroups as children then make the parent drawable. But I haven't seen any documentation to suggest this is possible:

// psuedo code only, may not even be possible
parent = L.FeatureGroup().addTo(map);
easel = L.FeatureGroup().addTo(map);
cluster = new L.MarkerClusterGroup(options);
map.draw = new L.Control.Draw({edit: {featureGroup: parent}});

You can use the Leaflet.FeatureGroup.SubGroup library for layers under easel as featureGroup under another featureGroup layer.


    var map = L.map("map"),
    parentGroup = L.markerClusterGroup(options), // Could be any other Layer Group type.
    // arrayOfMarkers refers to layers to be added under the parent group as sub group feature
    mySubGroup = L.featureGroup.subGroup(parentGroup, arrayOfMarkers);



  • From reading that github page, I can see that "Now adding the sub-group to the map adds clustered markers". I want one of the child groups to not cluster (the geofences) and the other subgroup to cluster (the markers). So this plugin may not help.
    – JK.
    Feb 14 '18 at 3:03
  • It is mentioned It should virtually be compatible with any LayerGroup plugin, not only MarkerCluster.
    – Shiko
    Feb 14 '18 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.