Skip to content

Commit

Permalink
Merge pull request #891 from boldtrn/issue_743
Browse files Browse the repository at this point in the history
Fix chunckedLoading LatLngBounds.intersects()
  • Loading branch information
danzel authored May 18, 2018
2 parents 74f81d5 + b865e42 commit 9b45d26
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 23 additions & 2 deletions spec/suites/removeLayersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
div.style.width = '200px';
div.style.height = '200px';
document.body.appendChild(div);

map = L.map(div, { maxZoom: 18, trackResize: false });

// Corresponds to zoom level 8 for the above div dimensions.
map.fitBounds(new L.LatLngBounds([
[1, 1],
Expand Down Expand Up @@ -171,4 +171,25 @@

expect(group.getLayers().length).to.be(0);
});

it('chunked loading zoom out', function () {
//See #743 for more details
var markers = [];

group = new L.MarkerClusterGroup({
chunkedLoading: true, chunkProgress: function () {
//Before this provoked an "undefined" exception
map.zoomOut();
group.removeLayers(markers);
}
});

for (var i = 1; i < 1000; i++) {
markers.push(new L.Marker([1.0 + (.0001 * i), 1.0 + (.0001 * i)]));
}

map.addLayer(group);

group.addLayers(markers);
});
});
3 changes: 3 additions & 0 deletions src/MarkerCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ export var MarkerCluster = L.MarkerCluster = L.Marker.extend({
if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) {
for (i = childClusters.length - 1; i >= 0; i--) {
c = childClusters[i];
if (c._boundsNeedUpdate) {
c._recalculateBounds();
}
if (boundsToApplyTo.intersects(c._bounds)) {
c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
}
Expand Down

0 comments on commit 9b45d26

Please sign in to comment.