@defra/interactive-map 0.0.15-alpha → 0.0.17-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/docusaurus.css +104 -0
- package/assets/images/favicon.svg +1 -0
- package/assets/images/hero.png +0 -0
- package/assets/images/slot-map.svg +264 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/slots.md +90 -6
- package/docs/api.md +4 -4
- package/docs/architecture.md +3 -1
- package/docs/{demo.mdx → examples.mdx} +1 -1
- package/docs/getting-started.md +5 -4
- package/docs/index.mdx +42 -0
- package/docs/plugins/datasets.md +561 -0
- package/docs/plugins/interact.md +176 -55
- package/docs/plugins/map-styles.md +64 -7
- package/docs/plugins/search.md +207 -63
- package/docs/plugins.md +8 -16
- package/docusaurus.config.cjs +34 -34
- package/jest.setup.js +1 -1
- package/package.json +6 -5
- package/plugins/beta/datasets/dist/css/index.css +85 -15
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/index.js +1 -1
- package/plugins/beta/datasets/src/DatasetsInit.jsx +24 -9
- package/plugins/beta/datasets/src/adapters/maplibre/index.js +18 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +113 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerIds.js +69 -0
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +338 -0
- package/plugins/beta/datasets/src/adapters/maplibre/patternRegistry.js +48 -0
- package/plugins/beta/datasets/src/api/addDataset.js +3 -9
- package/plugins/beta/datasets/src/api/getOpacity.js +17 -0
- package/plugins/beta/datasets/src/api/getStyle.js +13 -0
- package/plugins/beta/datasets/src/api/removeDataset.js +3 -45
- package/plugins/beta/datasets/src/api/setData.js +8 -0
- package/plugins/beta/datasets/src/api/setDatasetVisibility.js +37 -0
- package/plugins/beta/datasets/src/api/setFeatureVisibility.js +22 -0
- package/plugins/beta/datasets/src/api/setOpacity.js +29 -0
- package/plugins/beta/datasets/src/api/setStyle.js +22 -0
- package/plugins/beta/datasets/src/datasets.js +33 -59
- package/plugins/beta/datasets/src/defaults.js +43 -9
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +39 -30
- package/plugins/beta/datasets/src/fetch/fetchGeoJSON.js +2 -2
- package/plugins/beta/datasets/src/manifest.js +27 -19
- package/plugins/beta/datasets/src/panels/Key.jsx +129 -49
- package/plugins/beta/datasets/src/panels/Key.module.scss +48 -9
- package/plugins/beta/datasets/src/panels/Layers.jsx +131 -29
- package/plugins/beta/datasets/src/panels/Layers.module.scss +50 -8
- package/plugins/beta/datasets/src/reducer.js +128 -9
- package/plugins/beta/datasets/src/styles/patterns.js +157 -0
- package/plugins/beta/datasets/src/utils/bbox.js +8 -6
- package/plugins/beta/datasets/src/utils/filters.js +5 -2
- package/plugins/beta/datasets/src/utils/mergeSublayer.js +78 -0
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
- package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
- package/plugins/beta/draw-es/src/events.js +52 -20
- package/plugins/beta/draw-es/src/events.test.js +301 -0
- package/plugins/beta/draw-es/src/graphic.js +1 -1
- package/plugins/beta/draw-es/src/manifest.js +4 -4
- package/plugins/beta/draw-es/src/reducer.js +1 -1
- package/plugins/beta/draw-es/src/sketchViewModel.js +1 -1
- package/plugins/beta/draw-ml/dist/css/index.css +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +49 -52
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
- package/plugins/beta/draw-ml/src/api/split.js +4 -4
- package/plugins/beta/draw-ml/src/defaults.js +1 -1
- package/plugins/beta/draw-ml/src/draw.scss +0 -7
- package/plugins/beta/draw-ml/src/events.js +8 -6
- package/plugins/beta/draw-ml/src/manifest.js +29 -29
- package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
- package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
- package/plugins/beta/draw-ml/src/reducer.js +1 -1
- package/plugins/beta/draw-ml/src/undoStack.js +4 -4
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
- package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/src/Frame.jsx +9 -9
- package/plugins/beta/frame/src/FrameInit.jsx +4 -4
- package/plugins/beta/frame/src/api/addFrame.js +1 -1
- package/plugins/beta/frame/src/api/editFeature.js +1 -1
- package/plugins/beta/frame/src/config.js +1 -1
- package/plugins/beta/frame/src/manifest.js +3 -3
- package/plugins/beta/frame/src/reducer.js +1 -1
- package/plugins/beta/frame/src/utils.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/src/MapStyles.jsx +18 -18
- package/plugins/beta/map-styles/src/manifest.js +1 -1
- package/plugins/beta/scale-bar/dist/css/index.css +1 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
- package/plugins/beta/scale-bar/src/index.test.js +3 -3
- package/plugins/beta/scale-bar/src/manifest.js +3 -3
- package/plugins/beta/scale-bar/src/scaleBar.scss +2 -1
- package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
- package/plugins/beta/use-location/src/defaults.js +1 -1
- package/plugins/beta/use-location/src/events.js +3 -3
- package/plugins/interact/dist/css/index.css +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +1 -2
- package/plugins/interact/src/api/enable.js +8 -5
- package/plugins/interact/src/api/enable.test.js +2 -2
- package/plugins/interact/src/api/selectFeature.js +4 -4
- package/plugins/interact/src/api/unselectFeature.js +5 -5
- package/plugins/interact/src/defaults.js +0 -1
- package/plugins/interact/src/events.test.js +15 -15
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
- package/plugins/interact/src/interact.scss +0 -7
- package/plugins/interact/src/manifest.js +15 -19
- package/plugins/interact/src/manifest.test.js +6 -5
- package/plugins/interact/src/reducer.js +3 -3
- package/plugins/interact/src/reducer.test.js +0 -1
- package/plugins/interact/src/utils/spatial.js +10 -10
- package/plugins/interact/src/utils/spatial.test.js +14 -14
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +7 -6
- package/plugins/search/src/Search.test.jsx +23 -23
- package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
- package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +14 -14
- package/plugins/search/src/components/Form/Form.module.scss +2 -1
- package/plugins/search/src/components/Form/Form.test.jsx +11 -11
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
- package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
- package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
- package/plugins/search/src/datasets.js +12 -13
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +1 -1
- package/plugins/search/src/events/fetchSuggestions.js +3 -3
- package/plugins/search/src/events/fetchSuggestions.test.js +1 -1
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/index.js +2 -2
- package/plugins/search/src/events/index.test.js +2 -2
- package/plugins/search/src/events/inputHandlers.js +4 -4
- package/plugins/search/src/events/inputHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -2
- package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
- package/plugins/search/src/index.js +2 -1
- package/plugins/search/src/index.test.js +3 -3
- package/plugins/search/src/manifest.js +6 -4
- package/plugins/search/src/reducer.js +1 -2
- package/plugins/search/src/reducer.test.js +2 -2
- package/plugins/search/src/search.scss +10 -3
- package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
- package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
- package/plugins/search/src/utils/updateMap.js +1 -1
- package/plugins/search/src/utils/updateMap.test.js +5 -5
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +5 -5
- package/providers/beta/esri/src/utils/coords.js +1 -1
- package/providers/beta/esri/src/utils/esriFixes.js +1 -1
- package/providers/beta/esri/src/utils/query.js +4 -4
- package/providers/beta/esri/src/utils/spatial.js +1 -2
- package/providers/beta/esri/src/utils/spatial.test.js +4 -1
- package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/appEvents.test.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +3 -5
- package/providers/maplibre/src/mapEvents.test.js +15 -5
- package/providers/maplibre/src/maplibreProvider.test.js +6 -2
- package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
- package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
- package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +3 -2
- package/providers/maplibre/src/utils/highlightFeatures.test.js +13 -6
- package/providers/maplibre/src/utils/labels.js +19 -20
- package/providers/maplibre/src/utils/labels.test.js +15 -13
- package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
- package/providers/maplibre/src/utils/queryFeatures.js +6 -6
- package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
- package/providers/maplibre/src/utils/spatial.js +0 -1
- package/providers/maplibre/src/utils/spatial.test.js +26 -27
- package/src/App/components/Actions/Actions.jsx +2 -2
- package/src/App/components/Actions/Actions.module.scss +0 -7
- package/src/App/components/Actions/Actions.test.jsx +1 -1
- package/src/App/components/Icon/Icon.jsx +3 -2
- package/src/App/components/Icon/Icon.module.scss +4 -0
- package/src/App/components/Icon/Icon.test.jsx +43 -4
- package/src/App/components/MapButton/MapButton.jsx +42 -17
- package/src/App/components/MapButton/MapButton.module.scss +4 -13
- package/src/App/components/MapButton/MapButton.test.jsx +27 -3
- package/src/App/components/PopupMenu/PopupMenu.jsx +51 -274
- package/src/App/components/PopupMenu/PopupMenu.module.scss +14 -7
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +70 -1
- package/src/App/components/PopupMenu/usePopupMenu.js +258 -0
- package/src/App/hooks/useButtonStateEvaluator.js +12 -2
- package/src/App/hooks/useButtonStateEvaluator.test.js +38 -4
- package/src/App/hooks/useInterfaceAPI.js +6 -0
- package/src/App/hooks/useLayoutMeasurements.js +84 -18
- package/src/App/hooks/useLayoutMeasurements.test.js +124 -17
- package/src/App/layout/Layout.jsx +12 -7
- package/src/App/layout/Layout.test.jsx +2 -2
- package/src/App/layout/layout.module.scss +67 -29
- package/src/App/registry/pluginRegistry.js +17 -0
- package/src/App/registry/pluginRegistry.test.js +33 -0
- package/src/App/renderer/HtmlElementHost.jsx +2 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +7 -7
- package/src/App/renderer/mapButtons.js +3 -2
- package/src/App/renderer/mapPanels.test.js +2 -2
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +5 -5
- package/src/App/renderer/slots.js +9 -5
- package/src/App/store/AppProvider.jsx +3 -1
- package/src/App/store/AppProvider.test.jsx +1 -1
- package/src/App/store/ServiceProvider.jsx +3 -1
- package/src/App/store/appActionsMap.js +16 -0
- package/src/App/store/appActionsMap.test.js +27 -0
- package/src/App/store/appDispatchMiddleware.js +33 -1
- package/src/App/store/appDispatchMiddleware.test.js +250 -222
- package/src/App/store/appReducer.js +2 -0
- package/src/InteractiveMap/InteractiveMap.js +4 -0
- package/src/config/appConfig.js +7 -4
- package/src/config/events.js +28 -0
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_dimensions.scss +0 -1
- package/src/services/logger.js +6 -0
- package/src/services/logger.test.js +32 -0
- package/src/utils/getSafeZoneInset.js +9 -7
- package/src/utils/getSafeZoneInset.test.js +10 -10
- package/webpack.dev.mjs +23 -19
- package/docs/govuk-prototype.md +0 -23
- package/docs/index.md +0 -19
- package/plugins/beta/datasets/src/api/hideDataset.js +0 -14
- package/plugins/beta/datasets/src/api/hideFeatures.js +0 -41
- package/plugins/beta/datasets/src/api/showDataset.js +0 -14
- package/plugins/beta/datasets/src/api/showFeatures.js +0 -44
- package/plugins/beta/datasets/src/handleSetMapStyle.js +0 -54
- package/plugins/beta/datasets/src/mapLayers.js +0 -165
package/docs/plugins/interact.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
# Interact Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The interact plugin provides a unified way to handle user interactions for selecting map features or placing location markers.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```js
|
|
8
8
|
import createInteractPlugin from '@defra/interactive-map/plugins/interact'
|
|
9
9
|
|
|
10
|
-
const interactPlugin = createInteractPlugin(
|
|
10
|
+
const interactPlugin = createInteractPlugin({
|
|
11
|
+
interactionMode: 'auto',
|
|
12
|
+
multiSelect: true,
|
|
13
|
+
dataLayers: [
|
|
14
|
+
{ layerId: 'my-layer', idProperty: 'id' }
|
|
15
|
+
]
|
|
16
|
+
})
|
|
11
17
|
|
|
12
18
|
const interactiveMap = new InteractiveMap({
|
|
13
19
|
plugins: [interactPlugin]
|
|
@@ -34,20 +40,136 @@ Array of mode identifiers. When set, the plugin does not render when the app is
|
|
|
34
40
|
|
|
35
41
|
---
|
|
36
42
|
|
|
43
|
+
### `interactionMode`
|
|
44
|
+
**Type:** `'marker' | 'select' | 'auto'`
|
|
45
|
+
**Default:** `'marker'`
|
|
46
|
+
|
|
47
|
+
Controls how user clicks are interpreted.
|
|
48
|
+
|
|
49
|
+
- `'marker'` — clicking always places a location marker at the clicked coordinates
|
|
50
|
+
- `'select'` — clicking attempts to match a feature from `dataLayers`; click outside clears selection (unless `deselectOnClickOutside` is `false`)
|
|
51
|
+
- `'auto'` — attempts feature matching first, falls back to placing a marker if no feature is found
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### `dataLayers`
|
|
56
|
+
**Type:** `Array<DataLayer>`
|
|
57
|
+
**Default:** `[]`
|
|
58
|
+
|
|
59
|
+
Array of map layer configurations that are selectable. Each entry specifies which layer to watch and how to identify features.
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
dataLayers: [
|
|
63
|
+
{ layerId: 'my-polygons', idProperty: 'id' },
|
|
64
|
+
{ layerId: 'my-lines' }
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### `DataLayer` properties
|
|
69
|
+
|
|
70
|
+
| Property | Type | Description |
|
|
71
|
+
|----------|------|-------------|
|
|
72
|
+
| `layerId` | `string` | **Required.** The map layer identifier to enable selection on |
|
|
73
|
+
| `idProperty` | `string` | Property name used as the feature's unique identifier. If omitted, features are matched by index |
|
|
74
|
+
| `selectedStroke` | `string` | Overrides the global `selectedStroke` for this layer |
|
|
75
|
+
| `selectedFill` | `string` | Overrides the global `selectedFill` for this layer |
|
|
76
|
+
| `selectedStrokeWidth` | `number` | Overrides the global `selectedStrokeWidth` for this layer |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### `multiSelect`
|
|
81
|
+
**Type:** `boolean`
|
|
82
|
+
**Default:** `false`
|
|
83
|
+
|
|
84
|
+
When `true`, clicking additional features adds them to the selection rather than replacing it.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `contiguous`
|
|
89
|
+
**Type:** `boolean`
|
|
90
|
+
**Default:** `false`
|
|
91
|
+
|
|
92
|
+
When `true`, only features that touch or overlap the existing selection can be added. Uses spatial intersection to determine contiguity. Works with polygons, lines, and points.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### `deselectOnClickOutside`
|
|
97
|
+
**Type:** `boolean`
|
|
98
|
+
**Default:** `false`
|
|
99
|
+
|
|
100
|
+
When `true`, clicking outside any selectable layer clears the current selection.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### `tolerance`
|
|
105
|
+
**Type:** `number`
|
|
106
|
+
**Default:** `10`
|
|
107
|
+
|
|
108
|
+
Click detection radius in pixels. Increases the hit area around the cursor when matching features, which is useful for lines and points.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### `closeOnAction`
|
|
113
|
+
**Type:** `boolean`
|
|
114
|
+
**Default:** `true`
|
|
115
|
+
|
|
116
|
+
When `true`, the app closes after the user clicks "Done" or "Cancel".
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `markerColor`
|
|
121
|
+
**Type:** `string`
|
|
122
|
+
**Default:** `'rgba(212,53,28,1)'`
|
|
123
|
+
|
|
124
|
+
Color of the location marker placed on the map.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### `selectedStroke`
|
|
129
|
+
**Type:** `string`
|
|
130
|
+
**Default:** `'rgba(212,53,28,1)'`
|
|
131
|
+
|
|
132
|
+
Stroke color used to highlight selected features. Can be overridden per layer via `dataLayers`.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### `selectedFill`
|
|
137
|
+
**Type:** `string`
|
|
138
|
+
**Default:** `'rgba(255, 0, 0, 0.1)'`
|
|
139
|
+
|
|
140
|
+
Fill color used to highlight selected features. Can be overridden per layer via `dataLayers`.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### `selectedStrokeWidth`
|
|
145
|
+
**Type:** `number`
|
|
146
|
+
**Default:** `2`
|
|
147
|
+
|
|
148
|
+
Stroke width used to highlight selected features. Can be overridden per layer via `dataLayers`.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
37
152
|
## Methods
|
|
38
153
|
|
|
39
154
|
Methods are called on the plugin instance after the map is ready.
|
|
40
155
|
|
|
41
156
|
---
|
|
42
157
|
|
|
43
|
-
### `enable()`
|
|
158
|
+
### `enable(options?)`
|
|
159
|
+
|
|
160
|
+
Enable interaction mode. Shows action buttons and enables feature selection or marker placement. Accepts an optional options object to override any of the factory options at runtime.
|
|
44
161
|
|
|
45
|
-
|
|
162
|
+
| Parameter | Type | Description |
|
|
163
|
+
|-----------|------|-------------|
|
|
164
|
+
| `options` | `Object` | Optional. Any factory options to apply for this session |
|
|
46
165
|
|
|
47
166
|
```js
|
|
48
167
|
interactiveMap.on('map:ready', () => {
|
|
49
168
|
interactPlugin.enable()
|
|
50
169
|
})
|
|
170
|
+
|
|
171
|
+
// Override options at runtime
|
|
172
|
+
interactPlugin.enable({ multiSelect: true, interactionMode: 'select' })
|
|
51
173
|
```
|
|
52
174
|
|
|
53
175
|
---
|
|
@@ -72,26 +194,42 @@ interactPlugin.clear()
|
|
|
72
194
|
|
|
73
195
|
---
|
|
74
196
|
|
|
75
|
-
### `selectFeature(
|
|
197
|
+
### `selectFeature(featureInfo)`
|
|
76
198
|
|
|
77
199
|
Programmatically select a feature.
|
|
78
200
|
|
|
79
201
|
| Parameter | Type | Description |
|
|
80
202
|
|-----------|------|-------------|
|
|
81
|
-
| `
|
|
203
|
+
| `featureInfo.featureId` | `string` | The feature's identifier value |
|
|
204
|
+
| `featureInfo.layerId` | `string` | Optional. The layer the feature belongs to |
|
|
205
|
+
| `featureInfo.idProperty` | `string` | Optional. The property name used as the identifier |
|
|
82
206
|
|
|
83
207
|
```js
|
|
84
|
-
interactPlugin.selectFeature({
|
|
208
|
+
interactPlugin.selectFeature({
|
|
209
|
+
featureId: 'abc123',
|
|
210
|
+
layerId: 'my-layer',
|
|
211
|
+
idProperty: 'id'
|
|
212
|
+
})
|
|
85
213
|
```
|
|
86
214
|
|
|
215
|
+
Respects the current `multiSelect` setting — if `multiSelect` is `false`, the new feature replaces the existing selection.
|
|
216
|
+
|
|
87
217
|
---
|
|
88
218
|
|
|
89
|
-
### `unselectFeature()`
|
|
219
|
+
### `unselectFeature(featureInfo)`
|
|
90
220
|
|
|
91
|
-
|
|
221
|
+
Programmatically unselect a specific feature.
|
|
222
|
+
|
|
223
|
+
| Parameter | Type | Description |
|
|
224
|
+
|-----------|------|-------------|
|
|
225
|
+
| `featureInfo.featureId` | `string` | The feature's identifier value |
|
|
226
|
+
| `featureInfo.layerId` | `string` | Optional. The layer the feature belongs to |
|
|
227
|
+
| `featureInfo.idProperty` | `string` | Optional. The property name used as the identifier |
|
|
92
228
|
|
|
93
229
|
```js
|
|
94
|
-
interactPlugin.unselectFeature(
|
|
230
|
+
interactPlugin.unselectFeature({
|
|
231
|
+
featureId: 'abc123'
|
|
232
|
+
})
|
|
95
233
|
```
|
|
96
234
|
|
|
97
235
|
---
|
|
@@ -109,18 +247,22 @@ Emitted when the user confirms their selection (clicks "Done").
|
|
|
109
247
|
**Payload:**
|
|
110
248
|
```js
|
|
111
249
|
{
|
|
112
|
-
|
|
113
|
-
|
|
250
|
+
// If a marker was placed:
|
|
251
|
+
coords: [lng, lat],
|
|
252
|
+
|
|
253
|
+
// If features were selected:
|
|
254
|
+
selectedFeatures: [...],
|
|
255
|
+
selectionBounds: [west, south, east, north]
|
|
114
256
|
}
|
|
115
257
|
```
|
|
116
258
|
|
|
117
259
|
```js
|
|
118
|
-
interactiveMap.on('interact:done', (
|
|
119
|
-
if (
|
|
120
|
-
console.log('Location selected:',
|
|
260
|
+
interactiveMap.on('interact:done', (e) => {
|
|
261
|
+
if (e.coords) {
|
|
262
|
+
console.log('Location selected:', e.coords)
|
|
121
263
|
}
|
|
122
|
-
if (
|
|
123
|
-
console.log('
|
|
264
|
+
if (e.selectedFeatures) {
|
|
265
|
+
console.log('Features selected:', e.selectedFeatures)
|
|
124
266
|
}
|
|
125
267
|
})
|
|
126
268
|
```
|
|
@@ -129,7 +271,7 @@ interactiveMap.on('interact:done', ({ marker, selection }) => {
|
|
|
129
271
|
|
|
130
272
|
### `interact:cancel`
|
|
131
273
|
|
|
132
|
-
Emitted when the user cancels the interaction.
|
|
274
|
+
Emitted when the user cancels the interaction (clicks "Back").
|
|
133
275
|
|
|
134
276
|
**Payload:** None
|
|
135
277
|
|
|
@@ -141,65 +283,44 @@ interactiveMap.on('interact:cancel', () => {
|
|
|
141
283
|
|
|
142
284
|
---
|
|
143
285
|
|
|
144
|
-
### `interact:markerchange`
|
|
145
|
-
|
|
146
|
-
Emitted when the marker position changes.
|
|
147
|
-
|
|
148
|
-
**Payload:**
|
|
149
|
-
```js
|
|
150
|
-
{
|
|
151
|
-
coords: [lng, lat]
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
```js
|
|
156
|
-
interactiveMap.on('interact:markerchange', ({ coords }) => {
|
|
157
|
-
console.log('Marker moved to:', coords)
|
|
158
|
-
})
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
286
|
### `interact:selectionchange`
|
|
164
287
|
|
|
165
|
-
Emitted
|
|
288
|
+
Emitted whenever the feature selection changes.
|
|
166
289
|
|
|
167
290
|
**Payload:**
|
|
168
291
|
```js
|
|
169
292
|
{
|
|
170
|
-
|
|
171
|
-
|
|
293
|
+
selectedFeatures: [
|
|
294
|
+
{ featureId: '...', layerId: '...', properties: {...}, geometry: {...} }
|
|
295
|
+
],
|
|
296
|
+
selectionBounds: [west, south, east, north] | null,
|
|
297
|
+
canMerge: boolean, // true when all selected features are contiguous
|
|
298
|
+
canSplit: boolean // true when exactly one Polygon or MultiPolygon is selected
|
|
172
299
|
}
|
|
173
300
|
```
|
|
174
301
|
|
|
175
302
|
```js
|
|
176
|
-
interactiveMap.on('interact:selectionchange', (
|
|
177
|
-
console.log('
|
|
303
|
+
interactiveMap.on('interact:selectionchange', (e) => {
|
|
304
|
+
console.log('Selected features:', e.selectedFeatures)
|
|
305
|
+
console.log('Bounds:', e.selectionBounds)
|
|
178
306
|
})
|
|
179
307
|
```
|
|
180
308
|
|
|
181
309
|
---
|
|
182
310
|
|
|
183
|
-
### `interact:
|
|
311
|
+
### `interact:markerchange`
|
|
184
312
|
|
|
185
|
-
Emitted when a
|
|
313
|
+
Emitted when a location marker is placed or moved.
|
|
186
314
|
|
|
187
315
|
**Payload:**
|
|
188
316
|
```js
|
|
189
317
|
{
|
|
190
|
-
|
|
318
|
+
coords: [lng, lat]
|
|
191
319
|
}
|
|
192
320
|
```
|
|
193
321
|
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
### `interact:unselectFeature`
|
|
197
|
-
|
|
198
|
-
Emitted when a feature is programmatically unselected via the API.
|
|
199
|
-
|
|
200
|
-
**Payload:**
|
|
201
322
|
```js
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
}
|
|
323
|
+
interactiveMap.on('interact:markerchange', ({ coords }) => {
|
|
324
|
+
console.log('Marker moved to:', coords)
|
|
325
|
+
})
|
|
205
326
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Map Styles Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adds a UI control for switching between basemap styles and, where supported by the map provider, adjusting the map size.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -47,13 +47,22 @@ See [MapStyleConfig](../api/map-style-config.md) for full details.
|
|
|
47
47
|
createMapStylesPlugin({
|
|
48
48
|
mapStyles: [
|
|
49
49
|
{
|
|
50
|
-
id: '
|
|
51
|
-
label: '
|
|
52
|
-
url: '/styles/
|
|
50
|
+
id: 'outdoor',
|
|
51
|
+
label: 'Outdoor',
|
|
52
|
+
url: '/styles/outdoor.json',
|
|
53
53
|
appColorScheme: 'light',
|
|
54
54
|
mapColorScheme: 'light',
|
|
55
|
-
backgroundColor: '#
|
|
56
|
-
thumbnail: '/images/
|
|
55
|
+
backgroundColor: '#f5f5f0',
|
|
56
|
+
thumbnail: '/images/outdoor-thumb.png'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'dark',
|
|
60
|
+
label: 'Dark',
|
|
61
|
+
url: '/styles/dark.json',
|
|
62
|
+
appColorScheme: 'dark',
|
|
63
|
+
mapColorScheme: 'dark',
|
|
64
|
+
backgroundColor: '#1a1a1a',
|
|
65
|
+
thumbnail: '/images/dark-thumb.png'
|
|
57
66
|
}
|
|
58
67
|
]
|
|
59
68
|
})
|
|
@@ -75,10 +84,58 @@ Array of mode identifiers. When set, the plugin does not render when the app is
|
|
|
75
84
|
|
|
76
85
|
---
|
|
77
86
|
|
|
87
|
+
## Map size
|
|
88
|
+
|
|
89
|
+
When the active map provider supports map sizes (i.e. `mapProvider.capabilities.supportsMapSizes` is `true`), the panel also shows a map size control. This lets users choose between three size levels:
|
|
90
|
+
|
|
91
|
+
| Size | Description |
|
|
92
|
+
|------|-------------|
|
|
93
|
+
| `small` | Default size |
|
|
94
|
+
| `medium` | 1.5× scale |
|
|
95
|
+
| `large` | 2× scale |
|
|
96
|
+
|
|
97
|
+
Increasing the map size scales all features — labels, lines, polygons, and symbols — proportionally larger. If the map provider does not support this capability, the size control is not shown.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Persistence
|
|
102
|
+
|
|
103
|
+
The selected map style and map size are automatically saved to `localStorage` and restored on the next page load, keyed by the map instance ID. Users' choices therefore persist across sessions without any additional configuration.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
78
107
|
## Methods
|
|
79
108
|
|
|
80
109
|
This plugin does not expose any public methods.
|
|
81
110
|
|
|
111
|
+
---
|
|
112
|
+
|
|
82
113
|
## Events
|
|
83
114
|
|
|
84
|
-
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
### `map:setstyle`
|
|
118
|
+
|
|
119
|
+
Emitted when the user selects a map style.
|
|
120
|
+
|
|
121
|
+
**Payload:** The full [MapStyleConfig](../api/map-style-config.md) object for the selected style.
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
interactiveMap.on('map:setstyle', (mapStyle) => {
|
|
125
|
+
console.log('Style changed to:', mapStyle.id)
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### `map:setsize`
|
|
132
|
+
|
|
133
|
+
Emitted when the user selects a map size. Only fired when the map provider supports map sizes.
|
|
134
|
+
|
|
135
|
+
**Payload:** `'small' | 'medium' | 'large'`
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
interactiveMap.on('map:setsize', (size) => {
|
|
139
|
+
console.log('Map size changed to:', size)
|
|
140
|
+
})
|
|
141
|
+
```
|