Feature/lazy loading - #2331
Open
TobiasSodertalje wants to merge 5 commits into
Open
Conversation
Contributor
|
Appears to work rather well, for mobile users at least with the simulated touch input mode. Legends are gotten when groups are expanded then, else as soon as the cursor hovers over them. I encountered issues with WMS layers (which is what I've tested so far):
|
Contributor
|
To fix the missing root-group symbols the const addLayer = function addLayer(layer, {
position
} = {}) {
const styleName = layer.get('styleName') || null;
const layerStyle = styleName ? viewer.getStyle(styleName) : undefined;
const overlay = Overlay({
layer, style: layerStyle, position, viewer, localization
});
const groupName = layer.get('group');
if (rootGroupNames.includes(groupName)) {
rootGroup.addOverlay(overlay);
// Make sure remote symbols are loaded as root group is
// visible from start
activateLazyLegendImages(document.getElementById(overlay.getId()));
} else if (!(nonGroupNames.includes(groupName))) {
const groupCmp = groupCmps.find((cmp) => cmp.name === groupName);
if (groupCmp) {
groupCmp.addOverlay(overlay);
document.getElementById(groupCmp.getId()).classList.remove('hidden');
if (groupCmp.parent) {
updateLegend(groupCmp);
}
} else {
console.warn(`${localize('addLayerWarningGroup')} ${groupName} ${localize('addLayerWarningDNE')}`);
}
}
};or by passing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2321
Legend images are lazy-loaded by initially rendering them with data-legend-src instead of src. When a user interacts with the legend (hover/click/focus), we convert data-legend-src to src, which triggers the actual image request. This avoids loading all legend images up front and improves initial render performance.