From 11a1ff2f53de1eb47e161290ff1a78fbcba8ee9e Mon Sep 17 00:00:00 2001 From: sronveaux Date: Fri, 18 Oct 2024 20:36:57 +0200 Subject: [PATCH] First version of map composable to replace mapable mixin --- app-starter/components/SampleModule.vue | 19 ++- .../attributeTable/AttributeTable.vue | 9 +- .../attributeTable/AttributeTableWin.vue | 74 ++++++------ .../bglayerswitcher/BgLayerList.vue | 99 ++++++++-------- .../bglayerswitcher/BgLayerSwitcher.vue | 63 +++++----- src/components/geocoder/Geocoder.vue | 9 +- src/components/geolocator/Geolocator.vue | 13 ++- src/components/infoclick/InfoClickWin.vue | 23 ++-- src/components/layerlist/LayerList.vue | 67 ++++++----- src/components/maprecorder/MapRecorderWin.vue | 9 +- .../maxextentbutton/ZoomToMaxExtentButton.vue | 9 +- src/components/measuretool/MeasureResult.vue | 19 +-- src/components/measuretool/MeasureWin.vue | 59 ++++++---- src/components/modulecore/MapOverlay.vue | 55 +++++---- src/components/ol/Map.vue | 71 ++++++------ .../overviewmap/OverviewMapPanel.vue | 109 ++++++++++-------- src/components/progress/MapLoadingStatus.vue | 20 +++- src/mixins/Mapable.js | 32 ++--- 18 files changed, 445 insertions(+), 314 deletions(-) diff --git a/app-starter/components/SampleModule.vue b/app-starter/components/SampleModule.vue index 67836f08..95072024 100644 --- a/app-starter/components/SampleModule.vue +++ b/app-starter/components/SampleModule.vue @@ -30,7 +30,8 @@ // the module card is a the template for a typical Wegue module import ModuleCard from '../../src/components/modulecore/ModuleCard'; // we import a so called "mixin" that helps us to interact with the map -import { Mapable } from '../../src/mixins/Mapable'; +// import { Mapable } from '../../src/mixins/Mapable'; +import { useMap } from '../../src/composables/Map'; // an OpenLayers helper function to display coordinates import { toStringXY } from 'ol/coordinate'; // an OpenLayer helper function to transform coordinate reference systems @@ -39,7 +40,7 @@ import { transform } from 'ol/proj.js'; export default { name: 'sample-module', // make sure to register the 'Mapable' mixin - mixins: [Mapable], + // mixins: [Mapable], inheritAttrs: false, components: { 'wgu-module-card': ModuleCard @@ -48,12 +49,26 @@ export default { icon: { type: String, required: false, default: 'md:star' } }, // here we define variables that are used in the HTML above + setup () { + const { map, layers } = useMap(); + return { map, layers }; + }, data () { return { zoom: '', center: '' }; }, + watch: { + map: { + handler (newMap) { + if (newMap) { + this.onMapBound(); + } + }, + immediate: true + } + }, methods: { /** * This function is called once the map is bound to the application diff --git a/src/components/attributeTable/AttributeTable.vue b/src/components/attributeTable/AttributeTable.vue index 2ee0a058..1128b95b 100644 --- a/src/components/attributeTable/AttributeTable.vue +++ b/src/components/attributeTable/AttributeTable.vue @@ -28,7 +28,8 @@ diff --git a/src/components/bglayerswitcher/BgLayerList.vue b/src/components/bglayerswitcher/BgLayerList.vue index 504dfae3..9f41acd7 100644 --- a/src/components/bglayerswitcher/BgLayerList.vue +++ b/src/components/bglayerswitcher/BgLayerList.vue @@ -40,7 +40,8 @@ diff --git a/src/components/geocoder/Geocoder.vue b/src/components/geocoder/Geocoder.vue index 9ec34a65..6866f1c5 100644 --- a/src/components/geocoder/Geocoder.vue +++ b/src/components/geocoder/Geocoder.vue @@ -35,7 +35,8 @@ diff --git a/src/components/maprecorder/MapRecorderWin.vue b/src/components/maprecorder/MapRecorderWin.vue index 92a3904b..4f67c1ad 100644 --- a/src/components/maprecorder/MapRecorderWin.vue +++ b/src/components/maprecorder/MapRecorderWin.vue @@ -129,19 +129,24 @@