Max Wayne
Max Wayne

Reputation: 11

How to add a markercluster to Mapbox StoreLocator Template

i tried different ways to synchronize the cluster with the store locator. It is easy to add the cluster, but than i have some problems with the list on the left side.

My problem is, that i am not really sure how to integrate this function, that at the end the store locator works with the custom markers and the list is synchronize in the right way.

Store Locator: https://jsfiddle.net/sd5vt439/

L.mapbox.featureLayer('examples.map-h61e8o8e').on('ready', function(e) {
    var clusterGroup = new L.MarkerClusterGroup();
    e.target.eachLayer(function(layer) {
        clusterGroup.addLayer(layer);
    });
    map.addLayer(clusterGroup);
});

Upvotes: 0

Views: 239

Answers (1)

Max Wayne
Max Wayne

Reputation: 11

ok, i tried a little bit and it works now with nested functions:

locations.on('ready', function(e) {
  var clusterGroup = new L.MarkerClusterGroup();
    e.target.eachLayer(function(layer) {
        clusterGroup.addLayer(layer);
    });
    map.addLayer(clusterGroup);

    locations.eachLayer(function(locale) {
    ....
}

Upvotes: 1

Related Questions