Skip to content

Commit

Permalink
remove default zoomBounds and layerBounds for empty mapmlvectors
Browse files Browse the repository at this point in the history
  • Loading branch information
yhy0217 committed Sep 13, 2023
1 parent 03f0186 commit 6e12282
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/mapml/layers/FeatureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export var FeatureLayer = L.FeatureGroup.extend({
this.layerBounds = this.options.layerBounds
? this.options.layerBounds
: null;
this.zoomBounds = this.options.zoomBounds;
this.zoomBounds = this.options.zoomBounds
? this.options.zoomBounds
: null;
}
}
},
Expand Down Expand Up @@ -137,9 +139,10 @@ export var FeatureLayer = L.FeatureGroup.extend({

_handleMoveEnd: function () {
let mapZoom = this._map.getZoom(),
withinZoom =
mapZoom <= this.zoomBounds.maxZoom &&
mapZoom >= this.zoomBounds.minZoom;
withinZoom = this.zoomBounds
? mapZoom <= this.zoomBounds.maxZoom &&
mapZoom >= this.zoomBounds.minZoom
: false;
this.isVisible =
withinZoom &&
this._layers &&
Expand All @@ -157,8 +160,8 @@ export var FeatureLayer = L.FeatureGroup.extend({
_handleZoomEnd: function (e) {
let mapZoom = this._map.getZoom();
if (
mapZoom > this.zoomBounds.maxZoom ||
mapZoom < this.zoomBounds.minZoom
this.zoomBounds &&
(mapZoom > this.zoomBounds.maxZoom || mapZoom < this.zoomBounds.minZoom)
) {
this.clearLayers();
return;
Expand Down
2 changes: 0 additions & 2 deletions src/mapml/layers/MapMLLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1515,12 +1515,10 @@ export var MapMLLayer = L.Layer.extend({
pane: layer._container,
opacity: layer.options.opacity,
projection: layer._properties.projection,
layerBounds: M.getBounds(layer._content),
// by NOT passing options.extent, we are asking the FeatureLayer
// to dynamically update its .layerBounds property as features are
// added or removed from it
native: native,
zoomBounds: M.getZoomBounds(layer._content, native.zoom),
// each owned child layer gets a reference to the root layer
_leafletLayer: layer,
static: true,
Expand Down

0 comments on commit 6e12282

Please sign in to comment.