Skip to content

Commit

Permalink
Closes #938
Browse files Browse the repository at this point in the history
If the layerType is set as a base-layer in the config-mapper, it should be kept as a base-layer, *even if it has sub-layers*. The old behavior (before this commit) was that the base-layer was "transformed" to a "group-layer" if it had more than one subLayer. Since base-layers might be constructed with several subLayers, we shouldn't do that transformation... If the baseLayer is transformed to a "group-layer" we will get several errors, since the baseLayers does not contain all necessary information to render a "group-layer".
  • Loading branch information
Hallbergs committed Nov 30, 2021
1 parent b1448d0 commit fb5d83f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion new-client/src/models/layers/WMSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,34 @@ class WMSLayer {

this.layer.layersInfo = config.layersInfo;
this.layer.subLayers = this.subLayers;
this.layer.layerType = this.subLayers.length > 1 ? "group" : "layer";
this.layer.layerType = this.getLayerType();
this.layer.getSource().set("url", config.url);
this.type = "wms";
this.bindHandlers();
}

// If the layerType is set as a base-layer in the config-mapper,
// it should be kept as a base-layer, *even if it has sub-layers*.
// The old behavior (before this commit) was that the base-layer was
// "transformed" to a "group-layer" if it had more than one subLayer.
// Since base-layers might be constructed with several subLayers, we
// shouldn't do that transformation... If the baseLayer is transformed
// to a "group-layer" we will get several errors, since the baseLayers
// does not contain all necessary information to render a "group-layer".
getLayerType() {
// Destruct the layerType from the layerInfo
const { layerType } = this.layerInfo;
// Check if the type is set to "base", and if it is,
// return "base". If it is not, we check if we have more than
// one subLayer; if we do, we return "group", and otherwise it is
// a regular "layer".
return layerType === "base"
? "base"
: this.subLayers.length > 1
? "group"
: "layer";
}

/**
* Bind handlers for TileWMS and ImageWMS
* @instance
Expand Down

0 comments on commit fb5d83f

Please sign in to comment.