Skip to content

Commit 1d6d878

Browse files
AliyanHprushforth
authored andcommitted
WIP call setLayerElExtent even when features are hidden
1 parent d148f2d commit 1d6d878

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/map-feature.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,17 @@ export class MapFeature extends HTMLElement {
229229
// todo: dynamically update layer bounds of vector layer
230230
mapmlvectors.layerBounds = M.getBounds(this._layer._content);
231231
// update map's zoom limit
232-
// this._map._addZoomLimit(mapmlvectors);
232+
this._map._addZoomLimit(mapmlvectors);
233233
// TODO: can be set as a handler of featureLayer
234234
mapmlvectors._resetFeatures();
235235
L.extend(mapmlvectors.options, mapmlvectors.zoomBounds);
236236
}
237237
}
238238

239-
if (Object.keys(mapmlvectors._layers).length === 1) {
239+
// Number of features that are being displayed on the map
240+
let renderedFeatureCount = Object.keys(mapmlvectors._layers).length;
241+
// 0 because feature could be hidden by the min/max attr., 1 so as other features are added, _setLayerElExtent() is not run multiple times
242+
if (renderedFeatureCount === 1 || renderedFeatureCount === 0) {
240243
this._layer._setLayerElExtent();
241244
}
242245
this._setUpEvents();

src/mapml/layers/MapMLLayer.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,7 @@ export var MapMLLayer = L.Layer.extend({
375375
bounds.extend(this[type].layerBounds.max);
376376
}
377377
}
378-
} else if (
379-
// only process extent if mapmlvectors is not empty
380-
type === '_mapmlvectors' &&
381-
Object.keys(this[type]._layers).length !== 0
382-
) {
378+
} else if (type === '_mapmlvectors') {
383379
if (this[type].layerBounds) {
384380
if (!bounds) {
385381
bounds = this[type].layerBounds;

0 commit comments

Comments
 (0)