From f052d2d0e202278428e967dbf95331c0628f717d Mon Sep 17 00:00:00 2001 From: Pascal Barth Date: Mon, 4 Dec 2023 11:26:22 +0100 Subject: [PATCH] Add support for opacity of parent being carried through the layer groups works also with layer aggregates, so that the opacity set to the layer in the menu is given to all sub-layers/child-layers --- .../openlayers/OpenLayersExternalWMTSLayer.vue | 8 ++++++-- .../openlayers/OpenLayersGeoJSONLayer.vue | 8 ++++++-- .../openlayers/OpenLayersInternalLayer.vue | 14 +++++++++++++- .../components/openlayers/OpenLayersKMLLayer.vue | 8 ++++++-- .../openlayers/OpenLayersVectorLayer.vue | 8 ++++++-- .../components/openlayers/OpenLayersWMSLayer.vue | 8 ++++++-- .../components/openlayers/OpenLayersWMTSLayer.vue | 8 ++++++-- 7 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/modules/map/components/openlayers/OpenLayersExternalWMTSLayer.vue b/src/modules/map/components/openlayers/OpenLayersExternalWMTSLayer.vue index 4159a9985..a0568f2b3 100644 --- a/src/modules/map/components/openlayers/OpenLayersExternalWMTSLayer.vue +++ b/src/modules/map/components/openlayers/OpenLayersExternalWMTSLayer.vue @@ -15,12 +15,16 @@ const props = defineProps({ type: ExternalWMTSLayer, required: true, }, + parentLayerOpacity: { + type: Number, + default: null, + }, zIndex: { type: Number, default: -1, }, }) -const { externalWmtsLayerConfig, zIndex } = toRefs(props) +const { externalWmtsLayerConfig, parentLayerOpacity, zIndex } = toRefs(props) // mapping relevant store values const store = useStore() @@ -28,7 +32,7 @@ const projection = computed(() => store.state.position.projection) // extracting useful info from what we've linked so far const layerId = computed(() => externalWmtsLayerConfig.value.serverLayerId) -const opacity = computed(() => externalWmtsLayerConfig.value.opacity) +const opacity = computed(() => parentLayerOpacity.value || externalWmtsLayerConfig.value.opacity) const getCapabilitiesUrl = computed(() => externalWmtsLayerConfig.value.getURL()) const wmtsGetCapParser = new WMTSCapabilities() diff --git a/src/modules/map/components/openlayers/OpenLayersGeoJSONLayer.vue b/src/modules/map/components/openlayers/OpenLayersGeoJSONLayer.vue index d0407e476..18ae0bef6 100644 --- a/src/modules/map/components/openlayers/OpenLayersGeoJSONLayer.vue +++ b/src/modules/map/components/openlayers/OpenLayersGeoJSONLayer.vue @@ -18,12 +18,16 @@ const props = defineProps({ type: GeoAdminGeoJsonLayer, required: true, }, + parentLayerOpacity: { + type: Number, + default: null, + }, zIndex: { type: Number, default: -1, }, }) -const { geoJsonConfig, zIndex } = toRefs(props) +const { geoJsonConfig, parentLayerOpacity, zIndex } = toRefs(props) // mapping relevant store values const store = useStore() @@ -31,7 +35,7 @@ const projection = computed(() => store.state.position.projection) // extracting useful info from what we've linked so far const layerId = computed(() => geoJsonConfig.value.serverLayerId) -const opacity = computed(() => geoJsonConfig.value.opacity || 1.0) +const opacity = computed(() => parentLayerOpacity.value || geoJsonConfig.value.opacity) const geoJsonData = computed(() => geoJsonConfig.value.geoJsonData) const geoJsonStyle = computed(() => geoJsonConfig.value.geoJsonStyle) const isLoading = computed(() => geoJsonConfig.value.isLoading) diff --git a/src/modules/map/components/openlayers/OpenLayersInternalLayer.vue b/src/modules/map/components/openlayers/OpenLayersInternalLayer.vue index 885119c1e..9be45bc26 100644 --- a/src/modules/map/components/openlayers/OpenLayersInternalLayer.vue +++ b/src/modules/map/components/openlayers/OpenLayersInternalLayer.vue @@ -21,12 +21,16 @@ const props = defineProps({ type: AbstractLayer, default: null, }, + parentLayerOpacity: { + type: Number, + default: null, + }, zIndex: { type: Number, default: -1, }, }) -const { layerConfig, zIndex } = toRefs(props) +const { layerConfig, parentLayerOpacity, zIndex } = toRefs(props) const store = useStore() const projection = computed(() => store.state.position.projection) @@ -52,16 +56,19 @@ function shouldAggregateSubLayerBeVisible(subLayer) {