Skip to content

Commit 2b50c03

Browse files
AliyanHprushforth
authored andcommitted
Resolve layer extent and disable issue
Revert "Change (back) what StaticTileLayer.option._leafletLayer points to" This reverts commit 5240b23. Revert inadvertent test change (I think) that was causing a few failures
1 parent 1f71be2 commit 2b50c03

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

src/layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ export class MapLayer extends HTMLElement {
224224
// user checking/unchecking the layer from the layer control
225225
// this must be done *after* the layer is actually added to the map
226226
this._layer.on('add remove', this._onLayerChange, this);
227-
this._layer.on('add remove extentload', this._validateDisabled, this);
227+
this._layer.on('add remove foo', this._validateDisabled, this);
228228
// toggle the this.disabled attribute depending on whether the layer
229229
// is: same prj as map, within view/zoom of map
230-
this._layer._map.on('moveend', this._validateDisabled, this);
230+
this._layer._map.on('moveend layeradd', this._validateDisabled, this);
231231

232232
// if controls option is enabled, insert the layer into the overlays array
233233
if (this.parentNode._layerControl && !this.hidden) {

src/map-feature.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export class MapFeature extends HTMLElement {
216216
// if the <layer- > is not removed, then regenerate featureGroup and update the mapmlvectors accordingly
217217
let native = this._getNativeZoomAndCS(this._layer._content);
218218
this._featureGroup = mapmlvectors.addData(this, native.cs, native.zoom);
219+
this._layer._setLayerElExtent();
219220
mapmlvectors._layers[this._featureGroup._leaflet_id] = this._featureGroup;
220221
this._groupEl = this._featureGroup.options.group;
221222
if (mapmlvectors._staticFeature) {

src/mapml/layers/FeatureLayer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export var FeatureLayer = L.FeatureGroup.extend({
5252
}
5353
this.addData(mapml, native.cs, native.zoom);
5454
} else if (!mapml) {
55-
this.isVisible = true;
55+
this.isVisible = false;
5656
this.layerBounds = this.options.extent;
5757
this.zoomBounds = this.options.zoomBounds;
5858
}
@@ -201,6 +201,9 @@ export var FeatureLayer = L.FeatureGroup.extend({
201201
},
202202

203203
addData: function (mapml, nativeCS, nativeZoom) {
204+
if (mapml) {
205+
this.isVisible = true;
206+
}
204207
var features =
205208
mapml.nodeType === Node.DOCUMENT_NODE || mapml.nodeName === 'LAYER-'
206209
? mapml.getElementsByTagName('map-feature')

src/mapml/layers/MapMLLayer.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export var MapMLLayer = L.Layer.extend({
187187
this
188188
);
189189
}
190+
this._setLayerElExtent();
190191

191192
this.setZIndex(this.options.zIndex);
192193
this.getPane().appendChild(this._container);
@@ -368,7 +369,31 @@ export var MapMLLayer = L.Layer.extend({
368369
this._properties._mapExtents[i].templatedLayer.zoomBounds =
369370
zoomBounds;
370371
}
371-
} else {
372+
} else if (type === '_staticTileLayer') {
373+
if (this[type].layerBounds) {
374+
if (!bounds) {
375+
bounds = this[type].layerBounds;
376+
zoomBounds = this[type].zoomBounds;
377+
} else {
378+
bounds.extend(this[type].layerBounds.min);
379+
bounds.extend(this[type].layerBounds.max);
380+
}
381+
}
382+
} else if (type === '_imageLayer') {
383+
if (this[type].layerBounds) {
384+
if (!bounds) {
385+
bounds = this[type].layerBounds;
386+
zoomBounds = this[type].zoomBounds;
387+
} else {
388+
bounds.extend(this[type].layerBounds.min);
389+
bounds.extend(this[type].layerBounds.max);
390+
}
391+
}
392+
} else if (
393+
// only process extent if mapmlvectors is not empty
394+
type === '_mapmlvectors' &&
395+
Object.keys(this[type]._layers).length !== 0
396+
) {
372397
if (this[type].layerBounds) {
373398
if (!bounds) {
374399
bounds = this[type].layerBounds;
@@ -385,7 +410,7 @@ export var MapMLLayer = L.Layer.extend({
385410
//assigns the formatted extent object to .extent and spreads the zoom ranges to .extent also
386411
this._layerEl.extent = Object.assign(
387412
M._convertAndFormatPCRS(bounds, this._properties.crs),
388-
{ zoom: zoomBounds }
413+
{ zoom: zoomBounds, projection: this._properties.projection }
389414
);
390415
}
391416
},
@@ -868,7 +893,6 @@ export var MapMLLayer = L.Layer.extend({
868893
// if layer does not have a parent Element, do not need to set Controls
869894
layer._layerEl.parentElement._toggleControls();
870895
}
871-
layer._setLayerElExtent();
872896
layer.fire('foo', layer, false);
873897
// local functions
874898
// sets layer._properties.projection. Supposed to replace / simplify
@@ -1529,6 +1553,7 @@ export var MapMLLayer = L.Layer.extend({
15291553
layer._mapmlTileContainer.appendChild(tiles);
15301554
layer._staticTileLayer = M.staticTileLayer({
15311555
pane: layer._container,
1556+
_leafletLayer: layer,
15321557
projection: layer._properties.projection,
15331558
className: 'mapml-static-tile-layer',
15341559
tileContainer: layer._mapmlTileContainer,

src/mapml/layers/StaticTileLayer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export var StaticTileLayer = L.GridLayer.extend({
55
options.maxZoomBound
66
);
77
L.extend(options, this.zoomBounds);
8-
L.extend(options, { _leafletLayer: this });
98
L.setOptions(this, options);
109
this._groups = this._groupTiles(
1110
this.options.tileContainer.getElementsByTagName('map-tile')

test/e2e/mapml-viewer/mapml-viewer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</head>
2828

2929
<body>
30-
<mapml-viewer style="height: 600px;width:500px;" projection="CBMTILE" zoom="0" lat="47" lon="-92" controls>
30+
<mapml-viewer data-testid="testviewer" style="height: 600px;width:500px;" projection="CBMTILE" zoom="0" lat="47" lon="-92" controls>
3131
<layer- data-testid="testlayer" label="CBMT - INLINE" checked>
3232
<map-extent units="CBMTILE">
3333
<map-input name="zoomLevel" type="zoom" value="3" min="0" max="3" ></map-input>

0 commit comments

Comments
 (0)