Skip to content

Commit 812ed29

Browse files
committed
Fix opacity when the attribute is provided at page load, _opacity is
not set (setter not run), should return the attribute value if _opacity is nullish. Update to do list Work in progress - BNG and Feature Links (BC link) seem to have mutually exclusive solutions - zoomTo after changing projection on map is necessary to inform Leaflet of the changed CRS (scale difference) but the history gets messed up and the BC link doesn't quite render (you have to generate a moveend on the map, then it'll draw). Removed a section of code from _handleLink that sets the map viewer projection when there is a single map layer and it has a different projection from that of the map BECAUSE this is handled by the MapMLLayer in selectAlternateProjection and we don't want to trigger the promise involved in disconnecting / reconnecting all map layers (happens when mapml-viewer projection attribute changed callback happens).
1 parent 43be3f2 commit 812ed29

File tree

5 files changed

+56
-59
lines changed

5 files changed

+56
-59
lines changed

src/layer.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class MapLayer extends HTMLElement {
4848
}
4949

5050
get opacity() {
51+
// use ?? since 0 is falsy, || would return rhs in that case
5152
return this._opacity ?? this.getAttribute('opacity');
5253
}
5354

@@ -157,6 +158,8 @@ export class MapLayer extends HTMLElement {
157158
opacity: this.opacity
158159
}
159160
);
161+
this._attachedToMap();
162+
this._validateDisabled();
160163
resolve();
161164
})
162165
.catch((error) => {
@@ -170,23 +173,20 @@ export class MapLayer extends HTMLElement {
170173
mapprojection: this.parentElement.projection,
171174
opacity: this.opacity
172175
});
173-
resolve();
174-
}
175-
})
176-
.then(() => {
177176
this._attachedToMap();
178177
this._validateDisabled();
179-
})
180-
.catch((e) => {
181-
if (e.type === 'changeprojection') {
182-
this.src = e.detail.href;
183-
} else {
184-
console.log(e);
185-
this.dispatchEvent(
186-
new CustomEvent('error', { detail: { target: this } })
187-
);
188-
}
189-
});
178+
resolve();
179+
}
180+
}).catch((e) => {
181+
if (e.type === 'changeprojection') {
182+
this.src = e.detail.href;
183+
} else {
184+
console.log(e);
185+
this.dispatchEvent(
186+
new CustomEvent('error', { detail: { target: this } })
187+
);
188+
}
189+
});
190190
}
191191
_attachedToMap() {
192192
// set i to the position of this layer element in the set of layers

src/mapml-viewer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,12 @@ export class MapViewer extends HTMLElement {
360360
layersReady.push(reAttach.whenReady());
361361
}
362362
Promise.allSettled(layersReady).then(() => {
363-
this.zoomTo(lat, lon, zoom);
363+
// if don't do a zoomTo, the BNG experiment ends up at zoom=5 (incorrectly)
364+
// BUT the feature link from Canada/BC to BCTILE layer works
365+
// can have one but not both tbd
366+
//
364367
this._resetHistory();
368+
this.zoomTo(lat, lon, zoom);
365369
this._map.announceMovement.enable();
366370
});
367371
}

src/mapml/utils/Util.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,6 @@ export var Util = {
527527
}
528528
if (!link.inPlace && newLayer)
529529
layer.whenReady().then(() => {
530-
if (
531-
newLayer &&
532-
['_parent', '_self'].includes(link.target) &&
533-
layer.parentElement.querySelectorAll('layer-').length === 1
534-
)
535-
layer.parentElement.projection = layer._layer.getProjection();
536530
if (!layer.extent) {
537531
layer._layer._setLayerElExtent();
538532
}

test/e2e/layers/layerOpacityAttribute.test.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,27 @@ test.describe('Adding Opacity Attribute to the Layer- Element', () => {
1717
});
1818

1919
test('Setting Opacity Attibute to Layer- Element', async () => {
20+
await page.pause();
2021
let opacity_attribute_value = await page.$eval(
2122
'body > mapml-viewer > layer-',
2223
(layer) => layer.getAttribute('opacity')
2324
);
24-
if (!opacity_attribute_value) {
25-
return;
26-
} else {
27-
let layer_opacity = await page.$eval(
28-
'body > mapml-viewer > layer-',
29-
(layer) => layer.opacity
30-
);
31-
expect(layer_opacity).toEqual(opacity_attribute_value);
32-
}
25+
let layer_opacity = await page.$eval(
26+
'body > mapml-viewer > layer-',
27+
(layer) => layer.opacity
28+
);
29+
expect(layer_opacity).toEqual(opacity_attribute_value);
3330
});
3431
test('Opacity Slider Value Test', async () => {
32+
await page.pause();
3533
let opacity_slider_value = await page.$eval(
3634
'div > div.leaflet-control-container > div.leaflet-top.leaflet-right > div > section > div.leaflet-control-layers-overlays > fieldset > div:nth-child(2) > details > input[type=range]',
3735
(input) => input.value
3836
);
39-
if (!opacity_slider_value) {
40-
return;
41-
} else {
42-
let layer_opacity = await page.$eval(
43-
'body > mapml-viewer > layer-',
44-
(layer) => layer.opacity
45-
);
46-
expect(layer_opacity).toEqual(opacity_slider_value);
47-
}
37+
let layer_opacity = await page.$eval(
38+
'body > mapml-viewer > layer-',
39+
(layer) => layer.opacity
40+
);
41+
expect(layer_opacity).toEqual(opacity_slider_value);
4842
});
4943
});

todo-tests

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
23 failed
2-
core\featureIndexOverlay.test.js:96:7 › Feature Index Overlay test › Feature index content is correct on moveend
3-
core\featureIndexOverlay.test.js:112:7 › Feature Index Overlay test › Feature index overlay is hidden when empty, reticle still visible
4-
core\featureNavigation.test.js:19:9 › Playwright Keyboard Navigation + Query Layer Tests › Arrow Key Navigable Tests › Tab focuses inline features
5-
core\layerContextMenu.test.js:50:7 › Playwright Layer Context Menu Tests › Layer context menu copy layer
6-
7-
core\mapFeature.test.js:36:7 › Playwright MapFeature Custom Element Tests › MapFeature interactivity tests - feature is not in index order
8-
core\mapFeature.test.js:177:7 › Playwright MapFeature Custom Element Tests › Default click method test
9-
core\mapFeature.test.js:222:7 › Playwright MapFeature Custom Element Tests › Default focus method test
10-
core\projectionChange.test.js:19:9 › Playwright Projection Change Tests › Linked Feature Projection Change Tests › _self Linked Feature Change To OSMTILE
11-
core\projectionChange.test.js:57:9 › Playwright Projection Change Tests › Linked Feature Projection Change Tests › Debug components update with projection changes
12-
core\reticle.test.js:19:9 › Playwright Keyboard Navigation + Query Layer Tests › Crosshair Reticle Tests › Crosshair hidden onload, shows on focus
13-
layers\general\zoomLimit.js:17:9 › Playwright featureLayer (Static Features) Layer Tests › Map Zoom Limit Tests for featureLayer › Limit map zooming (zooming in)
14-
layers\general\zoomLimit.js:41:9 › Playwright featureLayer (Static Features) Layer Tests › Map Zoom Limit Tests for featureLayer › Limit map zooming (zooming out)
15-
layers\multipleQueryExtents.test.js:128:7 › Multiple Extent Query Tests › Only features from one extent are returned for queries inside its (non overlapping) bounds
16-
layers\multipleQueryExtents.test.js:161:7 › Multiple Extent Query Tests › No features returned when queried outside of bounds of all extents
17-
layers\queryableMapExtent.test.js:18:7 › Playwright Remote MapML with <map-extent> Tests › Query remote MapML document
18-
layers\templatedImageLayer.test.js:68:7 › Playwright templatedImage Layer Tests › Templated image layer - remove previous image on moveend
19-
mapml-viewer\customTCRS.test.js:46:7 › Playwright Custom TCRS Tests › Complex Custom TCRS, static features loaded, templated features loaded
1+
TODO
2+
3+
4+
experiments/linking/features - clicking on BC does not work, Ontario link not working
5+
experiments/vector tiles - not working
6+
experiments/custom-projections/Arctic-SDI/ Canada link not working
7+
8+
deal with flaky tests???
9+
10+
core/featureIndexOverlay test is broken, integrate other PR
11+
12+
get rid of 'foo' event
13+
split up and move createAndAdd functionality from onAdd to initialize + onAdd
14+
15+
dynamically update layer bounds as features added/removed from it
16+
17+
migrate some stuff from map-feature to FeatureLayer e.g. removeInFeatureList move it
18+
evaluate what belongs to what
19+
20+
refactor FeatureLayer into subclasses for static features, query features, templated features, templated tile features
21+
22+
add zoomend / layeradd event handler for FeatureLayer that checks what features should be rendered
23+
24+

0 commit comments

Comments
 (0)