Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix print layer custom order #4171

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions assets/src/components/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,26 @@ export default class Print extends HTMLElement {
opacityLayers.push(parseInt(255 * selectedBaseLayer.itemState.opacity * selectedBaseLayer.layerConfig.opacity));
}

// Add visible layers
for (const layer of mainLizmap.state.rootMapGroup.findMapLayers().slice().reverse()) {
// Add visible layers in defined order
const orderedVisibleLayers = {};
mainLizmap.state.rootMapGroup.findMapLayers().forEach(layer => {
if (layer.visibility) {
// Add layer to the list of printed layers
printLayers.push(layer.wmsName);
orderedVisibleLayers[layer.layerOrder] = layer;
}
});
for (const layerIndex of Object.keys(orderedVisibleLayers).reverse()) {
const layer = orderedVisibleLayers[layerIndex];
// Add layer to the list of printed layers
printLayers.push(layer.wmsName);

// Optionally add layer style if needed (same order as layers )
styleLayers.push(layer.wmsSelectedStyleName);
// Optionally add layer style if needed (same order as layers )
styleLayers.push(layer.wmsSelectedStyleName);

// Handle qgis layer opacity otherwise client value override it
if (layer.layerConfig?.opacity) {
opacityLayers.push(parseInt(255 * layer.opacity * layer.layerConfig.opacity));
} else {
opacityLayers.push(parseInt(255 * layer.opacity));
}
// Handle qgis layer opacity otherwise client value override it
if (layer.layerConfig?.opacity) {
opacityLayers.push(parseInt(255 * layer.opacity * layer.layerConfig.opacity));
} else {
opacityLayers.push(parseInt(255 * layer.opacity));
}
}

Expand Down
Loading
Loading