Skip to content

Commit

Permalink
Merge pull request #3849 from nboisteault/layer_order
Browse files Browse the repository at this point in the history
Handle QGIS `Control rendering order`
  • Loading branch information
nboisteault authored Aug 21, 2023
2 parents 35b0086 + 723f972 commit 9e86739
Show file tree
Hide file tree
Showing 4 changed files with 2,252 additions and 1 deletion.
5 changes: 5 additions & 0 deletions assets/src/modules/BaseLayersMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export default class BaseLayersMap extends olMap {
// Array of layers and groups in overlayLayerGroup
this._overlayLayersAndGroups = [];

const layersCount = mainLizmap.state.rootMapGroup.findMapLayers().length;

// Returns a layer or a layerGroup depending of the node type
const createNode = (node) => {
if(node.type === 'group'){
Expand Down Expand Up @@ -274,6 +276,9 @@ export default class BaseLayersMap extends olMap {
name: node.name
});

// OL layers zIndex is the reverse of layer's order given by cfg
layer.setZIndex(layersCount - 1 - node.layerOrder);

this._overlayLayersAndGroups.push(layer);
this._statesOlLayersandGroupsMap.set(node.name, [node, layer]);
return layer;
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/state/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ export class LayerGroupState extends LayerItemState {
**/
get layerOrder() {
if (this._layerOrder == -1) {
for (const layer of this.itemState.findLayers()) {
for (const layer of this.findLayers()) {
if (this._layerOrder == -1 || layer.layerOrder < this._layerOrder) {
this._layerOrder = layer.layerOrder;
}
Expand Down
Loading

0 comments on commit 9e86739

Please sign in to comment.