Skip to content

Commit

Permalink
Change multi selection to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
dopenguin committed Nov 7, 2024
1 parent 3a402ce commit ac3caba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/plugins/Gfi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
19 changes: 10 additions & 9 deletions packages/plugins/Gfi/src/store/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
1 change: 1 addition & 0 deletions packages/types/custom/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export interface GfiConfiguration extends PluginOptions {
*/
maxFeatures?: number
mode?: 'bboxDot' | 'intersects'
multiSelect?: boolean
renderType?: RenderType
}

Expand Down

0 comments on commit ac3caba

Please sign in to comment.