Skip to content

Commit c13be79

Browse files
prushforprushfor
authored andcommitted
Change FeatureLayer, no longer extend / shrink layerBounds as features
are added. Pass layerBounds to M.featureLayer initialize via option during initialization; use M.getBounds(mapml) to derive bounds from map-meta in the MapMLLayer._content (in the case of MapMLLayer._mapmlvectors), pass the derived bounds (from TemplatedFeaturesLayer.extentBounds and TemplatedTileLayer.extentBounds) when creating a FeatureLayer in those contexts. (templated layers' extentBounds property is derived from their child map-input axis min/max values, with the M._extractInputBounds utility).
1 parent bd6ef67 commit c13be79

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

src/mapml/layers/FeatureLayer.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export var FeatureLayer = L.FeatureGroup.extend({
5858
this.addData(mapml, native.cs, native.zoom);
5959
} else if (!mapml) {
6060
this.isVisible = false;
61-
this.bounds = this.options.bounds ? this.options.bounds : null;
61+
this.layerBounds = this.options.layerBounds
62+
? this.options.layerBounds
63+
: null;
6264
this.zoomBounds = this.options.zoomBounds;
6365
}
6466
},
@@ -278,16 +280,6 @@ export var FeatureLayer = L.FeatureGroup.extend({
278280
}
279281

280282
let layer = this.geometryToLayer(mapml, options, nativeCS, +zoom, title);
281-
if (!this.options.extent) {
282-
let ext = mapml.extent,
283-
xmin = ext.topLeft.pcrs.horizontal,
284-
ymin = ext.bottomRight.pcrs.vertical,
285-
xmax = ext.bottomRight.pcrs.horizontal,
286-
ymax = ext.topLeft.pcrs.vertical,
287-
bnd = L.bounds(L.point(xmin, ymin), L.point(xmax, ymax));
288-
289-
this.layerBounds = this.layerBounds ? this.layerBounds.extend(bnd) : bnd;
290-
}
291283
if (layer) {
292284
// if the layer is being used as a query handler output, it will have
293285
// a color option set. Otherwise, copy classes from the feature

src/mapml/layers/MapMLLayer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ export var MapMLLayer = L.Layer.extend({
15151515
pane: layer._container,
15161516
opacity: layer.options.opacity,
15171517
projection: layer._properties.projection,
1518+
layerBounds: M.getBounds(layer._content),
15181519
// by NOT passing options.extent, we are asking the FeatureLayer
15191520
// to dynamically update its .layerBounds property as features are
15201521
// added or removed from it

src/mapml/layers/TemplatedFeaturesLayer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export var TemplatedFeaturesLayer = L.Layer.extend({
3535
// pass the vector layer the container for the parent into which
3636
// it will append its own container for rendering into
3737
pane: container,
38-
// the extent will be static, fixed, constant for the lifetime of the layer
39-
bounds: this.extentBounds,
38+
// the bounds will be static, fixed, constant for the lifetime of the layer
39+
layerBounds: this.extentBounds,
4040
opacity: opacity,
4141
projection: map.options.projection,
4242
static: true,

src/mapml/layers/TemplatedTileLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export var TemplatedTileLayer = L.TileLayer.extend({
166166
let tileFeatures = M.featureLayer(null, {
167167
projection: this._map.options.projection,
168168
static: false,
169-
bounds: this.extentBounds,
169+
layerBounds: this.extentBounds,
170170
interactive: false
171171
});
172172

0 commit comments

Comments
 (0)