question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multiple MarkerClusterGroup on one map

See original GitHub issue

I have this code, but if i use more MarkerClusterGroup, result is strange. Clusters is not in layers, but all together and changing level (i) if i use zoom on map.

for(var i = 0; i < addressLayers.length; i++) {
    var cluster = new L.MarkerClusterGroup({
        iconCreateFunction: function(cl) {
            return new L.DivIcon({ html: '<div class="cluster'+i+'"><i></i><b><span>' + cl.getChildCount() + '</span></b></div>' });
        },
        maxClusterRadius: 50
    });
    for(var j = 0; j < addressLayers[i].length; j++){
        cluster.addLayer(addressLayers[i][j]);
    }
    map.addLayer(cluster);
}

Is there a way to have a cluster in layers?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ahoyahoycommented, Aug 18, 2014

i see http://jsfiddle.net/cxZRM/92/

sorry for mistake

0reactions
danzelcommented, Aug 18, 2014

No worries, enjoy 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using several Marker Cluster Groups displays overlapping ...
Simply create 1 subgroup per "switchable" Features Group and set their parent as your single Marker Cluster Group: var map = L.map('map', ...
Read more >
Leaflet.markercluster, markerClusterGroup into another ...
It behaves like a single marker cluster without any subgroups, ... you have to add them to map directly, not via main_cluster_test cluster:...
Read more >
Leaflet.markercluster | Marker Clustering plugin for Leaflet
Leaflet.markercluster. Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps. Requires Leaflet 1.0.0.
Read more >
Cluster multiple map services in leaflet
Solved: I am trying to cluster multiple layers in leaflet, ... as entire collections of features with the same geometry type in a...
Read more >
Leaflet Markercluster: How To Open Multiple Cluster ...
a marker sometimes goes missing when markers from more than one cluster It looks like you have multiple MarkerClusterGroups on your map.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found