@defra/interactive-map 0.0.18-alpha → 0.0.20-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 (91) hide show
  1. package/README.md +1 -1
  2. package/dist/css/index.css +1 -1
  3. package/dist/esm/im-core.js +1 -1
  4. package/dist/esm/im-shell.js +1 -1
  5. package/dist/umd/im-core.js +1 -1
  6. package/dist/umd/index.js +1 -1
  7. package/docs/api/button-definition.md +22 -5
  8. package/docs/api/map-style-config.md +2 -11
  9. package/docs/api/marker-config.md +19 -5
  10. package/docs/api/panel-definition.md +16 -0
  11. package/docs/api.md +101 -48
  12. package/docs/architecture.md +0 -2
  13. package/docs/assets/css/docusaurus.css +205 -0
  14. package/docs/assets/images/basic-map.jpg +0 -0
  15. package/docs/assets/images/button-first.jpg +0 -0
  16. package/{assets → docs/assets}/images/hero.png +0 -0
  17. package/docs/assets/images/marker-panel.jpg +0 -0
  18. package/docs/examples/add-marker-with-panel.mdx +123 -0
  19. package/docs/examples/basic-map.mdx +53 -0
  20. package/docs/examples/button-map.mdx +53 -0
  21. package/docs/examples/index.mdx +49 -0
  22. package/docs/getting-started.md +80 -53
  23. package/docs/index.mdx +1 -1
  24. package/docs/plugins/interact.md +32 -1
  25. package/docs/plugins.md +1 -1
  26. package/docusaurus.config.cjs +14 -5
  27. package/package.json +3 -3
  28. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  29. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
  30. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  31. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  32. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  33. package/plugins/beta/scale-bar/dist/css/index.css +1 -1
  34. package/plugins/beta/scale-bar/src/scaleBar.scss +1 -0
  35. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  36. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  37. package/plugins/interact/dist/umd/index.js +1 -1
  38. package/plugins/interact/src/InteractInit.jsx +5 -3
  39. package/plugins/interact/src/api/clear.js +1 -1
  40. package/plugins/interact/src/api/selectMarker.js +14 -0
  41. package/plugins/interact/src/api/selectMarker.test.js +25 -0
  42. package/plugins/interact/src/api/unselectMarker.js +14 -0
  43. package/plugins/interact/src/api/unselectMarker.test.js +14 -0
  44. package/plugins/interact/src/events.js +18 -30
  45. package/plugins/interact/src/events.test.js +113 -108
  46. package/plugins/interact/src/manifest.js +10 -2
  47. package/plugins/interact/src/reducer.js +36 -1
  48. package/plugins/interact/src/reducer.test.js +40 -1
  49. package/plugins/interact/src/utils/interactionModes.js +12 -0
  50. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  51. package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
  52. package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
  53. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  54. package/providers/maplibre/src/maplibreProvider.js +3 -2
  55. package/providers/maplibre/src/maplibreProvider.test.js +22 -0
  56. package/src/App/components/Panel/Panel.jsx +6 -6
  57. package/src/App/components/Panel/Panel.test.jsx +37 -0
  58. package/src/App/components/Viewport/Viewport.jsx +5 -15
  59. package/src/App/components/Viewport/Viewport.module.scss +2 -0
  60. package/src/App/components/Viewport/Viewport.test.jsx +16 -33
  61. package/src/App/hooks/useInterfaceAPI.js +7 -7
  62. package/src/App/hooks/useInterfaceAPI.test.js +15 -9
  63. package/src/App/hooks/useLayoutMeasurements.js +64 -72
  64. package/src/App/layout/Layout.jsx +1 -1
  65. package/src/App/layout/layout.module.scss +1 -8
  66. package/src/App/renderer/HtmlElementHost.jsx +10 -5
  67. package/src/App/renderer/mapPanels.js +2 -1
  68. package/src/App/store/appActionsMap.js +4 -4
  69. package/src/App/store/appActionsMap.test.js +10 -0
  70. package/src/InteractiveMap/InteractiveMap.js +61 -13
  71. package/src/InteractiveMap/InteractiveMap.test.js +130 -8
  72. package/src/InteractiveMap/domStateManager.js +18 -6
  73. package/src/InteractiveMap/domStateManager.test.js +21 -0
  74. package/src/InteractiveMap/historyManager.js +28 -16
  75. package/src/InteractiveMap/historyManager.test.js +17 -0
  76. package/src/config/appConfig.js +2 -1
  77. package/src/config/appConfig.test.js +3 -13
  78. package/src/config/defaults.js +2 -1
  79. package/src/config/events.js +20 -21
  80. package/src/services/closeApp.js +1 -10
  81. package/src/services/closeApp.test.js +3 -43
  82. package/src/services/eventBus.js +61 -0
  83. package/src/services/eventBus.test.js +70 -0
  84. package/src/types.js +6 -1
  85. package/src/utils/mapStateSync.js +48 -10
  86. package/src/utils/mapStateSync.test.js +29 -9
  87. package/assets/css/docusaurus.css +0 -104
  88. package/docs/examples.mdx +0 -70
  89. /package/docs/assets/{screens-blue.jpg → images/screens-blue.jpg} +0 -0
  90. /package/docs/assets/{screens-white.jpg → images/screens-white.jpg} +0 -0
  91. /package/{assets → docs/assets}/images/slot-map.svg +0 -0
package/docs/api.md CHANGED
@@ -27,18 +27,20 @@ Parameters:
27
27
 
28
28
  The `id` of a container element where the map will be rendered.
29
29
 
30
+ ---
31
+
30
32
  ### `options`
31
33
  **Type:** `Object`
32
34
 
33
35
  Configuration object specifying map provider, map style, behaviour, and other settings. See Options below.
34
36
 
37
+ > [!NOTE]
38
+ > In addition to the options below, any option supported by your map engine can be passed and will be forwarded to the provider constructor. See your map provider's documentation for available options (e.g., [MapLibre MapOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/)).
39
+
35
40
  ---
36
41
 
37
42
  ## Options
38
43
 
39
- > [!NOTE]
40
- > In addition to the options below, any option supported by your map engine can be passed and will be forwarded to the provider constructor. See your map provider's documentation for available options (e.g., [MapLibre MapOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/)).
41
-
42
44
  ---
43
45
 
44
46
  ### `appColorScheme`
@@ -47,8 +49,6 @@ Configuration object specifying map provider, map style, behaviour, and other se
47
49
 
48
50
  Colour scheme used by the application. Determines the colours of panels, buttons and controls.
49
51
 
50
- **Possible values**
51
-
52
52
  | Possible values |
53
53
  |:--|
54
54
  | **'light'** *(default)*
@@ -76,6 +76,18 @@ May be provided as:
76
76
  - A single CSS colour value applied to all map styles
77
77
  - An object keyed by map style ID, where each value is a valid CSS colour
78
78
 
79
+ ```js
80
+ // Single value applied to all map styles
81
+ new InteractiveMap('map', {
82
+ backgroundColor: '#f5f5f0'
83
+ })
84
+
85
+ // Keyed by map style ID
86
+ new InteractiveMap('map', {
87
+ backgroundColor: { outdoor: '#f5f5f0', dark: '#383F43' }
88
+ })
89
+ ```
90
+
79
91
  ---
80
92
 
81
93
  ### `behaviour`
@@ -84,16 +96,14 @@ May be provided as:
84
96
 
85
97
  Determines how and when the map is displayed.
86
98
 
87
- **Possible values**
88
-
89
99
  | Possible values |
90
100
  |:--|
91
101
  | **'buttonFirst'** *(default)*
92
- Map is initially hidden and a button is displayed in its place. Selecting the button opens the map in fullscreen mode. The optional `pageTitle` property is appended to the page title. This behaviour minimises resources downloaded when not all users need a map. |
102
+ Map is initially hidden and a button is displayed in its place. Selecting the button opens the map in fullscreen mode. The optional `pageTitle` property is appended to the page title. This provides a less intrusive experience for users who do not need or cannot use the map. It also minimises resources downloaded for services where the map is not central. |
93
103
  | **'inline'**
94
104
  The map is rendered inline with the body content and initially visible. |
95
105
  | **'hybrid'**
96
- A combination of button and inline behaviour, controlled by the optional `hybridWidth`. At smaller sizes a button is displayed; at larger sizes the map is rendered inline. When fullscreen, the optional `pageTitle` property is appended to the page title. |
106
+ A combination of buttonFirst and inline behaviour, controlled by the optional `hybridWidth`. At smaller sizes a button is displayed; at larger sizes the map is rendered inline. When fullscreen, the optional `pageTitle` property is appended to the page title. |
97
107
  | **'mapOnly'**
98
108
  Renders the map fullscreen on all devices, using the existing page title. |
99
109
 
@@ -129,7 +139,7 @@ The button is only displayed when the `behaviour` is `hybrid` or `buttonFirst`.
129
139
  ### `center`
130
140
  **Type:** `[number, number]`
131
141
 
132
- Initial center [lng, lat] or [easting, northing] depending on the crs of the map provider.
142
+ Initial centre [lng, lat] or [easting, northing] depending on the crs of the map provider.
133
143
 
134
144
  Passed directly to the underlying map engine.
135
145
 
@@ -139,7 +149,7 @@ Passed directly to the underlying map engine.
139
149
  **Type:** `string`
140
150
  **Default:** `'600px'`
141
151
 
142
- CSS height applied to the map container when the map is `inline`.
152
+ CSS height applied to the map container. Only used when the map is rendered inline; ignored when displayed fullscreen.
143
153
 
144
154
  ---
145
155
 
@@ -155,16 +165,16 @@ Message displayed when the user's device or browser is not supported.
155
165
  **Default:** `false`
156
166
 
157
167
  Whether a toggle button is displayed to allow the map to enter fullscreen mode.
158
- The button is only displayed when the map is `inline`.
168
+ The button is only displayed when the map is rendered inline.
159
169
 
160
170
  ---
161
171
 
162
172
  ### `enableZoomControls`
163
173
  **Type:** `boolean`
164
- **Default:** `false`
174
+ **Default:** `true`
165
175
 
166
176
  Whether zoom control buttons are displayed.
167
- Zoom controls are not diplayed when the interface type is `touch`.
177
+ Zoom controls are not displayed when the interface type is 'touch'.
168
178
 
169
179
  ---
170
180
 
@@ -189,7 +199,7 @@ Fallback error message shown when the map fails to load.
189
199
  **Default:** `false`
190
200
 
191
201
  Whether an exit button is displayed.
192
- The exit button is only displayed when the behavour is `buttonFirst` or `hybrid` and the map is `fullscreen`.
202
+ The exit button is only displayed when the behaviour is `buttonFirst` or `hybrid` and the map is displayed fullscreen.
193
203
 
194
204
  ---
195
205
 
@@ -197,7 +207,7 @@ The exit button is only displayed when the behavour is `buttonFirst` or `hybrid`
197
207
  **Type:** `number | null`
198
208
  **Default:** `null`
199
209
 
200
- Optional viewport width breakpoint (in pixels) used by the `'hybrid'` behaviour.
210
+ Optional viewport width breakpoint (in pixels) used by the `hybrid` behaviour.
201
211
  When not set, defaults to `maxMobileWidth`.
202
212
 
203
213
  ---
@@ -205,8 +215,10 @@ When not set, defaults to `maxMobileWidth`.
205
215
  ### `keyboardHintText`
206
216
  **Type:** `string`
207
217
 
208
- HTML string providing keyboard shortcut instructions for assistive technology users.
209
- The hint text is displayed as a popup label when the `viewport` has focus.
218
+ HTML string shown as a tooltip on the viewport when it receives keyboard focus, prompting the user to open the keyboard shortcuts modal.
219
+
220
+ > [!NOTE]
221
+ > It is unlikely you will need to override this. If you do, keep the text short to avoid breaking the layout of the tooltip.
210
222
 
211
223
  ---
212
224
 
@@ -214,8 +226,13 @@ The hint text is displayed as a popup label when the `viewport` has focus.
214
226
  **Type:** `string`
215
227
  **Required**
216
228
 
217
- Accessible label describing the purpose of the map.
218
- This value is announced to screen readers.
229
+ Accessible name for the map viewport, which has a role of `application`. This label is announced by screen readers when the viewport receives focus and should describe the purpose of the map.
230
+
231
+ ```js
232
+ new InteractiveMap('map', {
233
+ mapLabel: 'Flood risk areas in England'
234
+ })
235
+ ```
219
236
 
220
237
  ---
221
238
 
@@ -223,7 +240,13 @@ This value is announced to screen readers.
223
240
  **Type:** `function`
224
241
  **Required**
225
242
 
226
- A factory function that returns a map provider instance, e.g., `maplibreProvider()`.
243
+ A function that returns a map provider the abstraction layer that interfaces with the underlying map engine. It is called only when the map is opened so the provider code is not sent to the user unless needed.
244
+
245
+ ```js
246
+ new InteractiveMap('map', {
247
+ mapProvider: maplibreProvider()
248
+ })
249
+ ```
227
250
 
228
251
  ---
229
252
 
@@ -233,8 +256,6 @@ A factory function that returns a map provider instance, e.g., `maplibreProvider
233
256
 
234
257
  Visual size of text and features in the map itself.
235
258
 
236
- **Possible values**
237
-
238
259
  | Possible values |
239
260
  |:--|
240
261
  | **'small'** *(default)*
@@ -260,7 +281,7 @@ See [MapStyleConfig](./api/map-style-config.md) for full details.
260
281
  **Type:** `string`
261
282
  **Default:** `'mv'`
262
283
 
263
- URL query parameter key used to persist map visibility state.
284
+ URL query parameter key used to persist map visibility state. Override if the default value clashes with an existing parameter on your page.
264
285
 
265
286
  ---
266
287
 
@@ -276,9 +297,9 @@ See [MarkerConfig](./api/marker-config.md) for full details.
276
297
  ### `symbolDefaults`
277
298
  **Type:** `Partial<SymbolDefaults>`
278
299
 
279
- App-wide defaults for symbol and marker appearance. These values apply across all markers and datasets unless a more specific value is set at the symbol or per-marker level. Any property omitted here falls back to the built-in default:
300
+ App-wide defaults for symbol and marker appearance.
280
301
 
281
- | Property | Built-in default |
302
+ | Property | Default |
282
303
  |---|---|
283
304
  | `symbol` | `'pin'` |
284
305
  | `backgroundColor` | `'#ca3535'` |
@@ -302,7 +323,7 @@ See [Symbol Config](./api/symbol-config.md) for the full property list.
302
323
  ### `maxExtent`
303
324
  **Type:** `[number, number, number, number]`
304
325
 
305
- Maximum viewable extent [west, south, east, north]. Passed directly to the map engine; implementation varies.
326
+ Maximum viewable extent [west, south, east, north]. Passed directly to the underlying map engine; how it is enforced depends on the provider.
306
327
 
307
328
  ---
308
329
 
@@ -370,7 +391,7 @@ Smaller zoom increment used for fine-grained zoom adjustments.
370
391
  **Type:** `string`
371
392
 
372
393
  Supplementary text appended to the existing page title.
373
- Only used when the beahviour is `buttonFirst` or `hybrid` and the map is displayed in `fullscreen` mode.
394
+ Only used when the behaviour is `buttonFirst` or `hybrid` and the map is displayed fullscreen.
374
395
 
375
396
  ---
376
397
 
@@ -385,7 +406,7 @@ Distance (in pixels) the map pans during standard pan interactions.
385
406
  ### `plugins`
386
407
  **Type:** `PluginDescriptor[]`
387
408
 
388
- Plugins to load.
409
+ Optional extensions that add features such as datasets, search, or custom panels to the map.
389
410
 
390
411
  See [PluginDescriptor](./plugins/plugin-descriptor.md) for full details.
391
412
 
@@ -395,7 +416,7 @@ See [PluginDescriptor](./plugins/plugin-descriptor.md) for full details.
395
416
  **Type:** `boolean`
396
417
  **Default:** `false`
397
418
 
398
- Controls whether closing the map (via the browser back button or the exit map button when `hasExitButton` is `true` and the map is fullscreen) destroys the map instance or hides it while preserving its current state. Set to `true` to keep the map state intact, which is useful for implementations like a toggle map view list view pattern.
419
+ Controls whether closing the map destroys the map instance or hides it while preserving its current state. When `true`, state is retained between open and close for example in a map/list toggle, a user can interact with the map, switch to the list view, then reopen the map and pick up exactly where they left off.
399
420
 
400
421
  ---
401
422
 
@@ -405,22 +426,28 @@ Controls whether closing the map (via the browser back button or the exit map bu
405
426
 
406
427
  Whether map text labels can be selected and read aloud by assistive technologies.
407
428
 
408
- > [!WARNING]
409
- > **Experimental:** This is a development flag. It currently only works with MapLibre and specific styles. Do **not** enable in production unless fully tested.
429
+ > [!CAUTION]
430
+ > This is experimental. It currently only works with MapLibre and specific styles. Do **not** enable in production unless fully tested.
410
431
 
411
432
  ---
412
433
 
413
434
  ### `reverseGeocodeProvider`
414
435
  **Type:** `function | null`
415
436
 
416
- A factory function that returns a reverse geocode provider instance, e.g., `openNamesProvider()`.
437
+ A function that returns a reverse geocode provider used to convert map coordinates to a place name, for example when announcing the current map position to screen reader users. Like the map provider, it is only called when the map is opened so the provider code is not sent to the user unless needed.
438
+
439
+ ```js
440
+ new InteractiveMap('map', {
441
+ reverseGeocodeProvider: openNamesProvider()
442
+ })
443
+ ```
417
444
 
418
445
  ---
419
446
 
420
447
  ### `transformRequest`
421
448
  **Type:** `function`
422
449
 
423
- Function to transform outgoing requests (e.g., to add authentication headers). Passed directly to MapLibre; other map engines may have their own equivalent. For ESRI SDK, this is handled in the EsriMapProvider configuration.
450
+ Function to transform outgoing requests, for example to add authentication headers. This option is specific to MapLibre and is passed directly to the underlying MapLibre instance.
424
451
 
425
452
  ```js
426
453
  (url, resourceType) => { url, headers, credentials }
@@ -429,7 +456,7 @@ Function to transform outgoing requests (e.g., to add authentication headers). P
429
456
  See the [MapLibre documentation](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/RequestParameters/) for full details.
430
457
 
431
458
  > [!NOTE]
432
- > This function is synchronous. For asynchronous authentication flows such as OAuth, consider alternative approaches like overriding the fetch prototype. Further guidance to follow.
459
+ > For ESRI SDK, request transformation is handled in the EsriMapProvider configuration rather than through this option.
433
460
 
434
461
  ---
435
462
 
@@ -488,7 +515,9 @@ Add a marker to the map.
488
515
  |-----------|------|-------------|
489
516
  | `id` | `string` | Unique marker identifier |
490
517
  | `coords` | `[number, number]` | Coordinates [lng, lat] or [easting, northing] depending on CRS |
491
- | `options` | [`MarkerOptions`](./api/marker-config.md#markeroptions) | Optional marker appearance options |
518
+ | `options` | `MarkerOptions` | Optional marker appearance options |
519
+
520
+ See [MarkerOptions](./api/marker-config.md#markeroptions) for configuration options.
492
521
 
493
522
  ```js
494
523
  interactiveMap.addMarker('home', [-0.1276, 51.5074], { backgroundColor: '#1d70b8' })
@@ -550,14 +579,14 @@ interactiveMap.addButton('my-menu', {
550
579
 
551
580
  ### `addPanel(id, config)`
552
581
 
553
- Add a panel to the UI at runtime.
582
+ Adds a new panel with content to the UI at runtime. Focus is moved to the panel by default — set `focus: false` in the config to suppress this when adding panels on page load.
554
583
 
555
584
  | Parameter | Type | Description |
556
585
  |-----------|------|-------------|
557
586
  | `id` | `string` | Unique panel identifier |
558
587
  | `config` | `PanelDefinition` | Panel configuration |
559
588
 
560
- See [PanelDefinition](./api/panel-definition.md) for configuration options. When using this method, provide content via the `html` property.
589
+ See [PanelDefinition](./api/panel-definition.md) for all configuration options.
561
590
 
562
591
  ```js
563
592
  interactiveMap.addPanel('info-panel', {
@@ -573,7 +602,7 @@ interactiveMap.addPanel('info-panel', {
573
602
 
574
603
  ### `removePanel(id)`
575
604
 
576
- Remove a panel from the UI.
605
+ Removes a panel from the UI entirely. Use `hidePanel` instead if you want to show it again later.
577
606
 
578
607
  | Parameter | Type | Description |
579
608
  |-----------|------|-------------|
@@ -585,23 +614,27 @@ interactiveMap.removePanel('info-panel')
585
614
 
586
615
  ---
587
616
 
588
- ### `showPanel(id)`
617
+ ### `showPanel(id, options?)`
589
618
 
590
- Show a panel.
619
+ Shows a panel that already exists but is hidden. Focus is moved to the panel by default — set `focus: false` to suppress this, useful when you want focus to remain on the triggering button.
591
620
 
592
621
  | Parameter | Type | Description |
593
622
  |-----------|------|-------------|
594
623
  | `id` | `string` | Panel identifier to show |
624
+ | `options.focus` | `boolean` | Whether to move focus to the panel. Default: `true` |
595
625
 
596
626
  ```js
597
627
  interactiveMap.showPanel('info-panel')
628
+
629
+ // Keep focus on the triggering button
630
+ interactiveMap.showPanel('info-panel', { focus: false })
598
631
  ```
599
632
 
600
633
  ---
601
634
 
602
635
  ### `hidePanel(id)`
603
636
 
604
- Hide a panel.
637
+ Hides a panel without removing it, preserving its content for when it is shown again.
605
638
 
606
639
  | Parameter | Type | Description |
607
640
  |-----------|------|-------------|
@@ -628,7 +661,7 @@ See [ControlDefinition](./api/control-definition.md) for configuration options.
628
661
 
629
662
  ### `setMode(mode)`
630
663
 
631
- Set the application mode.
664
+ Programmatically set the application mode. See the [`mode`](#mode) option for more detail.
632
665
 
633
666
  | Parameter | Type | Description |
634
667
  |-----------|------|-------------|
@@ -642,7 +675,7 @@ interactiveMap.setMode('fullscreen')
642
675
 
643
676
  ### `toggleButtonState(id, prop, value)`
644
677
 
645
- Set or toggle a button state.
678
+ Set or toggle a button state. Where applicable the corresponding ARIA attribute is updated — `aria-pressed`, `aria-disabled`, or `aria-expanded`.
646
679
 
647
680
  | Parameter | Type | Description |
648
681
  |-----------|------|-------------|
@@ -698,15 +731,15 @@ interactiveMap.fitToBounds({
698
731
 
699
732
  ---
700
733
 
701
- ### `setView(opts)`
734
+ ### `setView(options)`
702
735
 
703
736
  Set the map center and zoom. Safe zone padding is automatically applied.
704
737
 
705
738
  | Parameter | Type | Description |
706
739
  |-----------|------|-------------|
707
- | `opts` | `Object` | View options |
708
- | `opts.center` | `[number, number]` | Optional center [lng, lat] or [easting, northing] depending on CRS |
709
- | `opts.zoom` | `number` | Optional zoom level |
740
+ | `options` | `Object` | View options |
741
+ | `options.center` | `[number, number]` | Optional center [lng, lat] or [easting, northing] depending on CRS |
742
+ | `options.zoom` | `number` | Optional zoom level |
710
743
 
711
744
  ```js
712
745
  interactiveMap.setView({ center: [-0.1276, 51.5074], zoom: 12 })
@@ -714,6 +747,26 @@ interactiveMap.setView({ center: [-0.1276, 51.5074], zoom: 12 })
714
747
 
715
748
  ---
716
749
 
750
+ ### `open()`
751
+
752
+ Programmatically open the map. Equivalent to the user clicking the open button. If the map has been hidden (e.g. in hybrid mode), it will be shown; otherwise the app will be loaded for the first time.
753
+
754
+ ```js
755
+ interactiveMap.open()
756
+ ```
757
+
758
+ ---
759
+
760
+ ### `close()`
761
+
762
+ Programmatically close the map. Triggers the same logic as the exit button. If `preserveStateOnClose` is `true`, the map is hidden but not destroyed; otherwise the app is removed entirely.
763
+
764
+ ```js
765
+ interactiveMap.close()
766
+ ```
767
+
768
+ ---
769
+
717
770
  ## Events
718
771
 
719
772
  Subscribe to events using `interactiveMap.on()` and unsubscribe with `interactiveMap.off()`.
@@ -32,8 +32,6 @@ This wrapper:
32
32
  * **Passes** configuration, plugins, and providers
33
33
  * **Exposes** events and methods to the host application
34
34
 
35
- > **Note:** Internally, the UI is implemented in React, but this is an implementation detail and not required knowledge for consumers.
36
-
37
35
  ---
38
36
 
39
37
  ## 2. Core Component
@@ -0,0 +1,205 @@
1
+ /* Custom styles for the Interactive Map docs site */
2
+
3
+ .app-section {
4
+ padding: 40px 0;
5
+ background-color: #ffffff;
6
+ }
7
+
8
+ .govuk-template__body.app-homepage .govuk-template__body-inner {
9
+ background-color: #f4f8fb;
10
+ }
11
+
12
+ .app-section--features {
13
+ background-color: #f4f8fb;
14
+ border-bottom: 1px solid #8eb8dc;
15
+ }
16
+
17
+ .app-prose-scope .app-section--features p:not(.app-no-prose *) {
18
+ margin-bottom: 0;
19
+ }
20
+
21
+ .app-section--features .govuk-grid-column-one-third:not(:first-child) {
22
+ margin-top: 30px;
23
+
24
+ @media (min-width: 48.125em) {
25
+ margin-top: 0;
26
+ }
27
+ }
28
+
29
+ /* Hero image */
30
+ .govuk-template--rebranded .app-masthead .govuk-grid-row {
31
+ @media (min-width: 48.125em) {
32
+ display: flex;
33
+ }
34
+ }
35
+
36
+ .govuk-template--rebranded .app-masthead .govuk-grid-column-one-third-from-desktop {
37
+ @media (min-width: 48.125em) {
38
+ background-image: url('/images/hero.png');
39
+ background-repeat: no-repeat;
40
+ background-position: center bottom;
41
+ background-size: 220px;
42
+ }
43
+ }
44
+
45
+ /* Color 100% */
46
+ .govuk-template--rebranded .app-masthead .govuk-button--inverse,
47
+ .govuk-template--rebranded .app-masthead .govuk-button--inverse:visited,
48
+ .govuk-template--rebranded .app-masthead .govuk-button--inverse:active,
49
+ .govuk-template--rebranded .app-masthead .govuk-button--inverse:hover {
50
+ color: #008531;
51
+ }
52
+
53
+ /* Background colour 100% */
54
+ .govuk-template--rebranded .govuk-header__link--homepage:not(:focus),
55
+ .govuk-template--rebranded .govuk-header,
56
+ .govuk-template--rebranded .govuk-service-navigation.govuk-service-navigation--inverse,
57
+ .govuk-template--rebranded .app-masthead {
58
+ background-color: #008531 !important;
59
+ }
60
+
61
+ /* Box shadow colur #083d29 */
62
+ .govuk-template--rebranded .app-masthead .govuk-button--inverse {
63
+ box-shadow: 0 2px 0 #0b5c3e;
64
+ }
65
+
66
+ /* Border colour 50% tint */
67
+ .govuk-template--rebranded .app-homepage .govuk-service-navigation--inverse .govuk-width-container {
68
+ border-color: #66B683 !important;
69
+ }
70
+
71
+ /* Example apps */
72
+ .app-example {
73
+ margin-bottom: 20px;
74
+ }
75
+
76
+ /* Example index cards */
77
+ .app-example-card {
78
+ position: relative;
79
+ margin-bottom: 30px;
80
+ border: 1px solid #b1b4b6;
81
+ }
82
+
83
+ .app-example-card > img {
84
+ display: block;
85
+ width: 100%;
86
+ }
87
+
88
+ .app-example-card__body {
89
+ padding: 15px;
90
+ }
91
+
92
+ .app-prose-scope *:not(.app-no-prose *) .app-example-card__body h2:last-child {
93
+ margin-bottom: 0;
94
+ }
95
+
96
+ .app-example-card__body .govuk-heading-m {
97
+ margin-bottom: 0;
98
+ }
99
+
100
+ .app-example-card .govuk-heading-m a::after {
101
+ content: '';
102
+ position: absolute;
103
+ inset: 0;
104
+ }
105
+
106
+ /* Fix sticky footer: the theme gives flex: 1 0 auto to any govuk-width-container
107
+ that is a direct child of govuk-template__body-inner, but the phase banner div
108
+ also matches that selector and grows incorrectly on short pages. Move the
109
+ flex-grow to <main> instead so only the content area stretches. */
110
+ .govuk-template--rebranded .govuk-template__body-inner > .govuk-width-container {
111
+ flex: none;
112
+ }
113
+
114
+ .govuk-template--rebranded .govuk-main-wrapper {
115
+ flex: 1 0 auto;
116
+ }
117
+
118
+ /* GOV.UK tabs — enhanced styles for all devices; React manages active state.
119
+ Extra specificity via .app-prose-scope required to override the theme. */
120
+ .govuk-tabs {
121
+ margin-top: 5px;
122
+ margin-bottom: 40px;
123
+ font-size: 1.1875rem;
124
+ line-height: 1.3157894737;
125
+ }
126
+
127
+ .app-prose-scope .govuk-tabs .govuk-tabs__list {
128
+ overflow: hidden;
129
+ margin: 0;
130
+ padding: 5px 0 0;
131
+ list-style: none;
132
+ border-bottom: 1px solid #b1b4b6;
133
+ }
134
+
135
+ .app-prose-scope .govuk-tabs .govuk-tabs__list-item {
136
+ position: relative;
137
+ float: left;
138
+ margin: 0 5px 0 0;
139
+ padding: 10px 20px;
140
+ background-color: #f3f2f1;
141
+ text-align: center;
142
+ }
143
+
144
+ .app-prose-scope .govuk-tabs__list-item::before {
145
+ content: none;
146
+ }
147
+
148
+ .app-prose-scope .govuk-tabs .govuk-tabs__list-item--selected {
149
+ margin-top: -5px;
150
+ padding: 14px 19px 15px;
151
+ border: 1px solid #b1b4b6;
152
+ border-bottom: 0;
153
+ background-color: #ffffff;
154
+ }
155
+
156
+ .app-prose-scope .govuk-tabs .govuk-tabs__tab {
157
+ display: inline-block;
158
+ margin-bottom: 0;
159
+ text-decoration: underline;
160
+ }
161
+
162
+ .app-prose-scope .govuk-tabs .govuk-tabs__tab:is(:link, :visited, :hover, :active) {
163
+ color: #0b0c0c;
164
+ }
165
+
166
+ .app-prose-scope .govuk-tabs .govuk-tabs__list-item--selected .govuk-tabs__tab {
167
+ text-decoration: none;
168
+ }
169
+
170
+ .app-prose-scope .govuk-tabs .govuk-tabs__tab::after {
171
+ content: "";
172
+ position: absolute;
173
+ inset: 0;
174
+ }
175
+
176
+ .app-prose-scope .govuk-tabs .govuk-tabs__panel {
177
+ padding: 0;
178
+ border: 1px solid #b1b4b6;
179
+ border-top: 0;
180
+ margin-bottom: 0;
181
+ }
182
+
183
+ .app-prose-scope .govuk-tabs .govuk-tabs__panel > :last-child {
184
+ margin-bottom: 0;
185
+ }
186
+
187
+ .app-prose-scope .govuk-tabs__panel--hidden {
188
+ display: none;
189
+ }
190
+
191
+ .app-prose-scope .govuk-tabs .app-code-block__pre {
192
+ margin: 0;
193
+ }
194
+
195
+ /* Heading overides */
196
+ .app-prose-scope *:not(.app-no-prose *) .govuk-heading-l {
197
+ font-size: 2.25rem;
198
+ line-height: 1.1111111111;
199
+ }
200
+
201
+ .app-prose-scope *:not(.app-no-prose *) .govuk-heading-m {
202
+ font-size: 1.5rem;
203
+ line-height: 1.25;
204
+ margin-bottom: 20px;
205
+ }
Binary file