From 928ad14b8784746bca27be87143c71c0c624bd3f Mon Sep 17 00:00:00 2001 From: sronveaux Date: Fri, 17 Nov 2023 09:18:27 +0100 Subject: [PATCH 1/3] Forward the layer to map overlays --- src/components/ol/HoverController.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/ol/HoverController.js b/src/components/ol/HoverController.js index b293ec6e..6d4a06af 100644 --- a/src/components/ol/HoverController.js +++ b/src/components/ol/HoverController.js @@ -1,14 +1,14 @@ import TileWmsSource from 'ol/source/TileWMS'; import ImageWMSSource from 'ol/source/ImageWMS'; import VectorSource from 'ol/source/Vector'; -import VectorTileSource from 'ol/source/VectorTile' +import VectorTileSource from 'ol/source/VectorTile'; import WMSGetFeatureInfo from 'ol/format/WMSGetFeatureInfo'; -import { WguEventBus } from '../../WguEventBus' +import { WguEventBus } from '../../WguEventBus'; import axios from 'axios'; export default class HoverController { DEFAULT_POINTER_REST_INTERVAL = 150; - DEFAULT_HOVER_OVERLAY = 'wgu-hover-tooltip' + DEFAULT_HOVER_OVERLAY = 'wgu-hover-tooltip'; map = null; timerHandle = null; @@ -101,7 +101,7 @@ export default class HoverController { featureInfos.push(...features.map((feat) => { return { layer, feature: feat }; })); - me.displayTooltip(featureInfos, coordinate) + me.displayTooltip(featureInfos, coordinate); }) .catch(function (error) { if (!axios.isCancel(error)) { @@ -114,7 +114,7 @@ export default class HoverController { featureInfos.push(...features.map((feat) => { return { layer, feature: feat }; })); - me.displayTooltip(featureInfos, coordinate) + me.displayTooltip(featureInfos, coordinate); } }); @@ -206,6 +206,7 @@ export default class HoverController { }; WguEventBus.$emit(overlayId + '-update-overlay', true, coordinate, { feature, + layer, hoverAttribute: hoverAttr }); me.activeOverlayId = overlayId; From f0dc661c5ff4c5982a34d02d3d303a733a39353b Mon Sep 17 00:00:00 2001 From: sronveaux Date: Fri, 17 Nov 2023 09:19:24 +0100 Subject: [PATCH 2/3] Ensure layer is forwarded inside unit tests --- tests/unit/specs/components/ol/HoverController.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/specs/components/ol/HoverController.spec.js b/tests/unit/specs/components/ol/HoverController.spec.js index ef047a19..8fe549cc 100644 --- a/tests/unit/specs/components/ol/HoverController.spec.js +++ b/tests/unit/specs/components/ol/HoverController.spec.js @@ -72,6 +72,7 @@ describe('ol/HoverController.js', () => { expect(visible).to.equal(true); expect(position).to.equal(undefined); expect(data.feature).to.equal(feat); + expect(data.layer).to.equal(layer); expect(data.hoverAttribute).to.equal('foo'); done(); }); From a852acf97cc7dccbf52656f16cc8086d143f3e27 Mon Sep 17 00:00:00 2001 From: sronveaux Date: Fri, 17 Nov 2023 09:20:06 +0100 Subject: [PATCH 3/3] Updated documentation with forwarded layer --- docs/reusable-components.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/reusable-components.md b/docs/reusable-components.md index 7055bb24..afc73207 100644 --- a/docs/reusable-components.md +++ b/docs/reusable-components.md @@ -35,6 +35,7 @@ An Overlay can either be statically positioned or can be used to implement a too ```javascript { feature: ol/Feature, + layer: ol/Layer, hoverAttribute: string } ``` @@ -70,7 +71,7 @@ export default { #### Feature hover tooltip -The following example implements a customized tooltip to render an attribute of a feature, when it is hovered on the map. Again, the default slot of `` is filled by a ``. A data object containing the `feature` and optionally `hoverAttribute` properties is available from the slot-scope. Declare the following vue template and add it to you `WguAppTemplate`: +The following example implements a customized tooltip to render an attribute of a feature, when it is hovered on the map. Again, the default slot of `` is filled by a ``. A data object containing the `feature`, `layer` and optionally `hoverAttribute` properties is available from the slot-scope. Declare the following vue template and add it to you `WguAppTemplate`: ```javascript