@defra/interactive-map 0.0.14-alpha → 0.0.16-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.
Files changed (199) hide show
  1. package/assets/css/docusaurus.css +104 -0
  2. package/assets/images/favicon.svg +1 -0
  3. package/assets/images/hero.png +0 -0
  4. package/dist/css/index.css +1 -1
  5. package/dist/esm/im-core.js +1 -1
  6. package/dist/umd/im-core.js +1 -1
  7. package/dist/umd/index.js +1 -1
  8. package/docs/api/slot-map.svg +1 -0
  9. package/docs/api/slots.md +89 -6
  10. package/docs/api.md +1 -1
  11. package/docs/architecture.md +3 -1
  12. package/docs/{demo.mdx → examples.mdx} +1 -1
  13. package/docs/getting-started.md +1 -3
  14. package/docs/index.mdx +42 -0
  15. package/docs/plugins/interact.md +176 -55
  16. package/docs/plugins/map-styles.md +64 -7
  17. package/docs/plugins/search.md +207 -63
  18. package/docs/plugins.md +7 -15
  19. package/docusaurus.config.cjs +34 -34
  20. package/jest.setup.js +1 -1
  21. package/package.json +5 -4
  22. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  23. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
  24. package/plugins/beta/datasets/src/DatasetsInit.jsx +1 -1
  25. package/plugins/beta/datasets/src/api/addDataset.js +1 -1
  26. package/plugins/beta/datasets/src/api/hideDataset.js +1 -1
  27. package/plugins/beta/datasets/src/api/hideFeatures.js +1 -1
  28. package/plugins/beta/datasets/src/api/removeDataset.js +1 -1
  29. package/plugins/beta/datasets/src/api/showDataset.js +1 -1
  30. package/plugins/beta/datasets/src/api/showFeatures.js +1 -1
  31. package/plugins/beta/datasets/src/datasets.js +4 -4
  32. package/plugins/beta/datasets/src/defaults.js +1 -1
  33. package/plugins/beta/datasets/src/fetch/createDynamicSource.js +5 -5
  34. package/plugins/beta/datasets/src/handleSetMapStyle.js +1 -1
  35. package/plugins/beta/datasets/src/manifest.js +7 -7
  36. package/plugins/beta/datasets/src/mapLayers.js +2 -3
  37. package/plugins/beta/datasets/src/panels/Key.jsx +31 -29
  38. package/plugins/beta/datasets/src/panels/Layers.jsx +8 -9
  39. package/plugins/beta/datasets/src/utils/bbox.js +4 -4
  40. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  41. package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
  42. package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
  43. package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
  44. package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
  45. package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
  46. package/plugins/beta/draw-es/src/events.js +52 -20
  47. package/plugins/beta/draw-es/src/events.test.js +301 -0
  48. package/plugins/beta/draw-es/src/graphic.js +1 -1
  49. package/plugins/beta/draw-es/src/manifest.js +4 -4
  50. package/plugins/beta/draw-es/src/reducer.js +1 -1
  51. package/plugins/beta/draw-es/src/sketchViewModel.js +1 -1
  52. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  53. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  54. package/plugins/beta/draw-ml/src/DrawInit.jsx +49 -52
  55. package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
  56. package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
  57. package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
  58. package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
  59. package/plugins/beta/draw-ml/src/api/split.js +4 -4
  60. package/plugins/beta/draw-ml/src/defaults.js +1 -1
  61. package/plugins/beta/draw-ml/src/events.js +8 -6
  62. package/plugins/beta/draw-ml/src/manifest.js +15 -15
  63. package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
  64. package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
  65. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
  66. package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
  67. package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
  68. package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
  69. package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
  70. package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
  71. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
  72. package/plugins/beta/draw-ml/src/reducer.js +1 -1
  73. package/plugins/beta/draw-ml/src/undoStack.js +4 -4
  74. package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
  75. package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
  76. package/plugins/beta/frame/src/Frame.jsx +4 -4
  77. package/plugins/beta/frame/src/FrameInit.jsx +4 -4
  78. package/plugins/beta/frame/src/api/addFrame.js +1 -1
  79. package/plugins/beta/frame/src/api/editFeature.js +1 -1
  80. package/plugins/beta/frame/src/config.js +1 -1
  81. package/plugins/beta/frame/src/manifest.js +3 -3
  82. package/plugins/beta/frame/src/reducer.js +1 -1
  83. package/plugins/beta/frame/src/utils.js +1 -1
  84. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  85. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  86. package/plugins/beta/map-styles/src/MapStyles.jsx +18 -18
  87. package/plugins/beta/map-styles/src/manifest.js +2 -2
  88. package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
  89. package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
  90. package/plugins/beta/use-location/src/defaults.js +1 -1
  91. package/plugins/beta/use-location/src/events.js +3 -3
  92. package/plugins/interact/src/InteractInit.jsx +1 -2
  93. package/plugins/interact/src/api/enable.js +8 -5
  94. package/plugins/interact/src/api/enable.test.js +2 -2
  95. package/plugins/interact/src/api/selectFeature.js +4 -4
  96. package/plugins/interact/src/api/unselectFeature.js +5 -5
  97. package/plugins/interact/src/defaults.js +0 -1
  98. package/plugins/interact/src/events.test.js +15 -15
  99. package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
  100. package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
  101. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
  102. package/plugins/interact/src/manifest.js +2 -2
  103. package/plugins/interact/src/manifest.test.js +3 -4
  104. package/plugins/interact/src/reducer.js +3 -3
  105. package/plugins/interact/src/reducer.test.js +0 -1
  106. package/plugins/interact/src/utils/spatial.js +10 -10
  107. package/plugins/interact/src/utils/spatial.test.js +14 -14
  108. package/plugins/search/dist/css/index.css +1 -1
  109. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  110. package/plugins/search/dist/esm/index.js +1 -1
  111. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  112. package/plugins/search/dist/umd/index.js +1 -1
  113. package/plugins/search/src/Search.jsx +7 -6
  114. package/plugins/search/src/Search.test.jsx +23 -23
  115. package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
  116. package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
  117. package/plugins/search/src/components/Form/Form.jsx +14 -14
  118. package/plugins/search/src/components/Form/Form.test.jsx +11 -11
  119. package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
  120. package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
  121. package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
  122. package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
  123. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
  124. package/plugins/search/src/datasets.js +12 -13
  125. package/plugins/search/src/datasets.test.js +1 -1
  126. package/plugins/search/src/defaults.js +1 -1
  127. package/plugins/search/src/events/fetchSuggestions.js +4 -4
  128. package/plugins/search/src/events/fetchSuggestions.test.js +5 -5
  129. package/plugins/search/src/events/formHandlers.js +3 -3
  130. package/plugins/search/src/events/formHandlers.test.js +1 -1
  131. package/plugins/search/src/events/index.js +2 -2
  132. package/plugins/search/src/events/index.test.js +2 -2
  133. package/plugins/search/src/events/inputHandlers.js +4 -4
  134. package/plugins/search/src/events/inputHandlers.test.js +1 -1
  135. package/plugins/search/src/events/suggestionHandlers.js +2 -2
  136. package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
  137. package/plugins/search/src/index.js +2 -1
  138. package/plugins/search/src/index.test.js +3 -3
  139. package/plugins/search/src/manifest.js +6 -4
  140. package/plugins/search/src/reducer.js +1 -2
  141. package/plugins/search/src/reducer.test.js +2 -2
  142. package/plugins/search/src/search.scss +18 -6
  143. package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
  144. package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
  145. package/plugins/search/src/utils/updateMap.js +1 -1
  146. package/plugins/search/src/utils/updateMap.test.js +5 -5
  147. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
  148. package/providers/beta/esri/src/esriProvider.js +5 -5
  149. package/providers/beta/esri/src/utils/coords.js +1 -1
  150. package/providers/beta/esri/src/utils/esriFixes.js +1 -1
  151. package/providers/beta/esri/src/utils/query.js +4 -4
  152. package/providers/beta/esri/src/utils/spatial.js +1 -2
  153. package/providers/beta/esri/src/utils/spatial.test.js +4 -1
  154. package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
  155. package/providers/maplibre/src/appEvents.test.js +1 -1
  156. package/providers/maplibre/src/index.js +1 -1
  157. package/providers/maplibre/src/index.test.js +3 -5
  158. package/providers/maplibre/src/mapEvents.test.js +15 -5
  159. package/providers/maplibre/src/maplibreProvider.test.js +6 -2
  160. package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
  161. package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
  162. package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
  163. package/providers/maplibre/src/utils/highlightFeatures.js +2 -2
  164. package/providers/maplibre/src/utils/highlightFeatures.test.js +12 -6
  165. package/providers/maplibre/src/utils/labels.js +19 -20
  166. package/providers/maplibre/src/utils/labels.test.js +15 -13
  167. package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
  168. package/providers/maplibre/src/utils/queryFeatures.js +6 -6
  169. package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
  170. package/providers/maplibre/src/utils/spatial.js +0 -1
  171. package/providers/maplibre/src/utils/spatial.test.js +26 -27
  172. package/src/App/components/Panel/Panel.module.scss +1 -0
  173. package/src/App/hooks/useLayoutMeasurements.js +1 -10
  174. package/src/App/hooks/useLayoutMeasurements.test.js +2 -5
  175. package/src/App/hooks/useVisibleGeometry.js +7 -13
  176. package/src/App/hooks/useVisibleGeometry.test.js +72 -47
  177. package/src/App/layout/Layout.jsx +0 -3
  178. package/src/App/layout/Layout.test.jsx +0 -1
  179. package/src/App/layout/layout.module.scss +11 -77
  180. package/src/App/registry/pluginRegistry.js +17 -0
  181. package/src/App/registry/pluginRegistry.test.js +33 -0
  182. package/src/App/renderer/HtmlElementHost.jsx +0 -1
  183. package/src/App/renderer/HtmlElementHost.test.jsx +20 -11
  184. package/src/App/renderer/mapButtons.js +3 -2
  185. package/src/App/renderer/mapPanels.test.js +3 -3
  186. package/src/App/renderer/slotHelpers.js +2 -2
  187. package/src/App/renderer/slotHelpers.test.js +3 -3
  188. package/src/App/renderer/slots.js +0 -3
  189. package/src/App/store/AppProvider.jsx +0 -1
  190. package/src/App/store/appDispatchMiddleware.js +33 -1
  191. package/src/App/store/appDispatchMiddleware.test.js +250 -222
  192. package/src/config/appConfig.js +4 -4
  193. package/src/utils/getSafeZoneInset.js +139 -42
  194. package/src/utils/getSafeZoneInset.test.js +298 -122
  195. package/src/utils/logger.js +6 -0
  196. package/src/utils/logger.test.js +32 -0
  197. package/webpack.dev.mjs +22 -18
  198. package/docs/govuk-prototype.md +0 -23
  199. package/docs/index.md +0 -19
@@ -1,13 +1,19 @@
1
1
  # Interact Plugin
2
2
 
3
- Select features or place markers on the map. The interact plugin provides a unified way to handle user interactions for selecting map features or placing location markers.
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
- Enable interaction mode. Shows action buttons and enables feature selection or marker placement.
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(feature)`
197
+ ### `selectFeature(featureInfo)`
76
198
 
77
199
  Programmatically select a feature.
78
200
 
79
201
  | Parameter | Type | Description |
80
202
  |-----------|------|-------------|
81
- | `feature` | `Object` | Feature object to select |
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({ id: 'feature-1', bounds: [...] })
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
- Clear the currently selected feature.
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
- marker: { coords: [lng, lat] } | null,
113
- selection: { bounds: [...], feature: {...} } | null
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', ({ marker, selection }) => {
119
- if (marker) {
120
- console.log('Location selected:', marker.coords)
260
+ interactiveMap.on('interact:done', (e) => {
261
+ if (e.coords) {
262
+ console.log('Location selected:', e.coords)
121
263
  }
122
- if (selection) {
123
- console.log('Feature selected:', selection.feature)
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 when the feature selection changes.
288
+ Emitted whenever the feature selection changes.
166
289
 
167
290
  **Payload:**
168
291
  ```js
169
292
  {
170
- bounds: [west, south, east, north],
171
- feature: { ... }
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', ({ bounds, feature }) => {
177
- console.log('Selection changed:', feature)
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:selectFeature`
311
+ ### `interact:markerchange`
184
312
 
185
- Emitted when a feature is programmatically selected via the API.
313
+ Emitted when a location marker is placed or moved.
186
314
 
187
315
  **Payload:**
188
316
  ```js
189
317
  {
190
- feature: { ... }
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
- feature: { ... }
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
- Map style switching plugin that adds a UI control for changing the basemap appearance and the map size.
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: 'default',
51
- label: 'Default',
52
- url: '/styles/default.json',
50
+ id: 'outdoor',
51
+ label: 'Outdoor',
52
+ url: '/styles/outdoor.json',
53
53
  appColorScheme: 'light',
54
54
  mapColorScheme: 'light',
55
- backgroundColor: '#f5f5f5',
56
- thumbnail: '/images/default-thumb.png'
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
- This plugin does not emit any custom events. Style changes are handled internally and update the map automatically.
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
+ ```