Skip to content

Commit

Permalink
Fix onZoomEnd bug: only remove affected features based on their zoom
Browse files Browse the repository at this point in the history
and the zoom of the map.
  • Loading branch information
prushforth committed Sep 26, 2023
1 parent 8f0925b commit 3aaa9d1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/mapml/layers/FeatureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,10 @@ export var FeatureLayer = L.FeatureGroup.extend({
},

_handleZoomEnd: function (e) {
let mapZoom = this._map.getZoom();
if (
this.zoomBounds &&
(mapZoom > this.zoomBounds.maxZoom || mapZoom < this.zoomBounds.minZoom)
) {
this.clearLayers();
return;
// handle zoom end gets called twice for every zoom, this condition makes it go through once only.
if (this.zoomBounds) {
this._resetFeatures();
}
this._resetFeatures();
},

// remove or add features based on the min max attribute of the features,
Expand Down

0 comments on commit 3aaa9d1

Please sign in to comment.