Skip to content

Commit

Permalink
Merge pull request #187 from Geoportail-Luxembourg/GITLAB-28-fix_add_…
Browse files Browse the repository at this point in the history
…layer

allow to add a layer from another theme
  • Loading branch information
rmichaelis authored Jan 30, 2025
2 parents 3bfa7cb + fe034d9 commit 9463e14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/catalog/catalog-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function toggleParent(node: LayerTreeNodeModel, is3d: boolean) {
}
function toggleLayer(node: LayerTreeNodeModel, is3d: boolean) {
layers.toggleLayer(+node.id, !node.checked, is3d)
layers.toggleLayer(+node.id, !node.checked, is3d, true)
}
</script>

Expand Down
12 changes: 9 additions & 3 deletions src/composables/layers/layers.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,21 @@ export default function useLayers() {
}
}

function toggleLayer(id: LayerId, show = true, is3d: boolean) {
function toggleLayer(
id: LayerId,
show = true,
is3d: boolean,
fromCurrentTheme: boolean
) {
const themeStore = useThemeStore()
const mapStore = useMapStore()

// the cast from ThemeNodeModel | undefined to Layer might not be correct.
// in the themes fixture only WMS layers correspond to the Layer definition,
// whereas WMTS layers have "layer" property
const store = is3d ? themeStore.layerTrees_3d : themeStore.theme
const layer = <Layer>themes.findById(id, store)
const layer = <Layer>(
themes.findById(id, fromCurrentTheme ? store : undefined)
)

if (layer) {
const linkedLayers = layer.metadata?.linked_layers || []
Expand Down

0 comments on commit 9463e14

Please sign in to comment.