From ac3cabaddafa6112d04da0f3a448224d671500d3 Mon Sep 17 00:00:00 2001 From: Pascal Roehling Date: Thu, 7 Nov 2024 10:01:54 +0100 Subject: [PATCH] Change multi selection to be configurable --- packages/plugins/Gfi/README.md | 1 + .../plugins/Gfi/src/store/actions/index.ts | 19 ++++++++++--------- packages/types/custom/core.ts | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/plugins/Gfi/README.md b/packages/plugins/Gfi/README.md index 85fbe6cd0..c8d6b9fad 100644 --- a/packages/plugins/Gfi/README.md +++ b/packages/plugins/Gfi/README.md @@ -22,6 +22,7 @@ The GFI plugin can be used to fetch and optionally display GFI (GetFeatureInfo) | gfiContentComponent | VueConstructor? | Allows overriding the GfiContent.vue component for custom design and functionality. Coding knowledge is required to use this feature, as any implementation will have to rely upon the VueX store model. Please refer to the implementation. | | maxFeatures | number? | Limits the viewable GFIs per layer by this number. The first n elements are chosen arbitrarily. Useful if you e.g. just want one result, or to limit an endless stream of returns to e.g. 10. Infinite by default. | | mode | enum["bboxDot", "intersects"]? | Method of calculating which feature has been chosen by the user. `bboxDot` utilizes the `bbox`-url parameter using the clicked coordinate while `intersects` uses a `Filter` to calculate the intersected features. Layers can have their own `gfiMode` parameter which would override this global mode. To apply this, add the desired value to the parameter in the `mapConfiguration`. Defaults to `'bboxDot'`. | +| multiSelect | boolean? | If set to `true`, multiple features can be selected at once by using the modifier key (CTRL on Windows or Command on macOS) and dragging the mouse. Similar to `gfi.directSelect`, features can be added and removed by selection / unselecting them. Does not work together with `extendedMasterportalapiMarkers` of `@polar/core`. Defaults to `false`. | | renderType | ('iconMenu' \| 'independent')? | Only relevant if `window` is set to `true` for at least one layer. Whether the gfi plugin is rendered independently or as part of the IconMenu. Defaults to 'independent'. | For details on the `displayComponent` attribute, refer to the [Global Plugin Parameters](../../core/README.md#global-plugin-parameters) section of `@polar/core`. diff --git a/packages/plugins/Gfi/src/store/actions/index.ts b/packages/plugins/Gfi/src/store/actions/index.ts index 1da396c22..c3216b264 100644 --- a/packages/plugins/Gfi/src/store/actions/index.ts +++ b/packages/plugins/Gfi/src/store/actions/index.ts @@ -81,15 +81,16 @@ export const makeActions = () => { } }, setupMultiSelection({ dispatch, getters, rootGetters }) { - const dragBox = new DragBox({ condition: platformModifierKeyOnly }) - dragBox.on('boxend', () => - dispatch('getFeatureInfo', { - coordinateOrExtent: dragBox.getGeometry().getExtent(), - modifierPressed: true, - }) - ) - rootGetters.map.addInteraction(dragBox) - + if (getters.gfiConfiguration.multiSelect) { + const dragBox = new DragBox({ condition: platformModifierKeyOnly }) + dragBox.on('boxend', () => + dispatch('getFeatureInfo', { + coordinateOrExtent: dragBox.getGeometry().getExtent(), + modifierPressed: true, + }) + ) + rootGetters.map.addInteraction(dragBox) + } if (getters.gfiConfiguration.directSelect) { rootGetters.map.on('click', ({ coordinate, originalEvent }) => dispatch('getFeatureInfo', { diff --git a/packages/types/custom/core.ts b/packages/types/custom/core.ts index 75acea0f0..226a4f84e 100644 --- a/packages/types/custom/core.ts +++ b/packages/types/custom/core.ts @@ -378,6 +378,7 @@ export interface GfiConfiguration extends PluginOptions { */ maxFeatures?: number mode?: 'bboxDot' | 'intersects' + multiSelect?: boolean renderType?: RenderType }