Skip to content

Commit

Permalink
Work in progress - BNG and Feature Links (BC link) seem to have
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
prushforth committed Sep 20, 2023
1 parent 0307930 commit 42a5f7d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
29 changes: 14 additions & 15 deletions src/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ export class MapLayer extends HTMLElement {
opacity: this.opacity
}
);
this._attachedToMap();
this._validateDisabled();
resolve();
})
.catch((error) => {
Expand All @@ -171,23 +173,20 @@ export class MapLayer extends HTMLElement {
mapprojection: this.parentElement.projection,
opacity: this.opacity
});
resolve();
}
})
.then(() => {
this._attachedToMap();
this._validateDisabled();
})
.catch((e) => {
if (e.type === 'changeprojection') {
this.src = e.detail.href;
} else {
console.log(e);
this.dispatchEvent(
new CustomEvent('error', { detail: { target: this } })
);
}
});
resolve();
}
}).catch((e) => {
if (e.type === 'changeprojection') {
this.src = e.detail.href;
} else {
console.log(e);
this.dispatchEvent(
new CustomEvent('error', { detail: { target: this } })
);
}
});
}
_attachedToMap() {
// set i to the position of this layer element in the set of layers
Expand Down
6 changes: 5 additions & 1 deletion src/mapml-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,12 @@ export class MapViewer extends HTMLElement {
layersReady.push(reAttach.whenReady());
}
Promise.allSettled(layersReady).then(() => {
this.zoomTo(lat, lon, zoom);
// if don't do a zoomTo, the BNG experiment ends up at zoom=5 (incorrectly)
// BUT the feature link from Canada/BC to BCTILE layer works
// can have one but not both tbd
//
this._resetHistory();
this.zoomTo(lat, lon, zoom);
this._map.announceMovement.enable();
});
}
Expand Down
6 changes: 0 additions & 6 deletions src/mapml/utils/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,6 @@ export var Util = {
}
if (!link.inPlace && newLayer)
layer.whenReady().then(() => {
if (
newLayer &&
['_parent', '_self'].includes(link.target) &&
layer.parentElement.querySelectorAll('layer-').length === 1
)
layer.parentElement.projection = layer._layer.getProjection();
if (!layer.extent) {
layer._layer._setLayerElExtent();
}
Expand Down

0 comments on commit 42a5f7d

Please sign in to comment.