@defra/interactive-map 0.0.30-alpha → 0.0.32-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 (247) hide show
  1. package/README.md +2 -2
  2. package/assets/images/bright-ofm-thumb.jpg +0 -0
  3. package/assets/images/dark-ofm-thumb.jpg +0 -0
  4. package/assets/images/road-ofm-thumb.jpg +0 -0
  5. package/assets/templates/add-polygons.njk +143 -0
  6. package/assets/templates/add-symbols.njk +119 -0
  7. package/assets/templates/{map.njk → basic-map.njk} +9 -17
  8. package/assets/templates/button-map.njk +56 -0
  9. package/assets/templates/draw-tools.njk +161 -0
  10. package/assets/templates/marker-panel.njk +91 -0
  11. package/assets/templates/place-marker.njk +104 -0
  12. package/assets/templates/search-control.njk +98 -0
  13. package/assets/templates/select-feature.njk +101 -0
  14. package/assets/templates/style-switcher.njk +87 -0
  15. package/assets/templates/toggle-marker-label.njk +74 -0
  16. package/dist/css/index.css +1 -1
  17. package/dist/esm/im-core.js +1 -1
  18. package/dist/esm/im-shell.js +1 -1
  19. package/dist/umd/im-core.js +1 -1
  20. package/dist/umd/index.js +1 -1
  21. package/docs/api/context.md +4 -4
  22. package/docs/api.md +166 -37
  23. package/docs/assets/css/docusaurus.scss +36 -4
  24. package/docs/assets/images/add-polygons.jpg +0 -0
  25. package/docs/assets/images/add-symbols.jpg +0 -0
  26. package/docs/assets/images/basic-map.jpg +0 -0
  27. package/docs/assets/images/button-first.jpg +0 -0
  28. package/docs/assets/images/deuteranopia-ozs-map-thumb.jpg +0 -0
  29. package/docs/assets/images/draw.jpg +0 -0
  30. package/docs/assets/images/marker-panel.jpg +0 -0
  31. package/docs/assets/images/night-ozs-map-thumb.jpg +0 -0
  32. package/docs/assets/images/outdoor-ozs-map-thumb.jpg +0 -0
  33. package/docs/assets/images/place-marker.jpg +0 -0
  34. package/docs/assets/images/screenshot.jpg +0 -0
  35. package/docs/assets/images/search.jpg +0 -0
  36. package/docs/assets/images/select-feature.jpg +0 -0
  37. package/docs/assets/images/style-switcher.jpg +0 -0
  38. package/docs/assets/images/toggle-marker-label.jpg +0 -0
  39. package/docs/assets/images/tritanopia-ozs-map-thumb.jpg +0 -0
  40. package/docs/examples/add-marker-with-panel.mdx +3 -3
  41. package/docs/examples/add-polygons.mdx +225 -0
  42. package/docs/examples/add-symbols.mdx +177 -0
  43. package/docs/examples/basic-map.mdx +2 -2
  44. package/docs/examples/draw-tools.mdx +271 -0
  45. package/docs/examples/index.mdx +95 -11
  46. package/docs/examples/place-marker.mdx +151 -0
  47. package/docs/examples/search-control.mdx +71 -0
  48. package/docs/examples/select-feature.mdx +146 -0
  49. package/docs/examples/style-switcher.mdx +135 -0
  50. package/docs/examples/toggle-marker-label.mdx +3 -3
  51. package/docs/plugins/datasets.md +157 -122
  52. package/docs/plugins/interact.md +1 -4
  53. package/docusaurus.config.cjs +9 -2
  54. package/govuk-prototype-kit.config.json +52 -2
  55. package/package.json +1 -1
  56. package/plugins/beta/datasets/dist/css/index.css +5 -2
  57. package/plugins/beta/datasets/dist/esm/im-datasets-ml-adapter.js +1 -0
  58. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  59. package/plugins/beta/datasets/dist/esm/index.js +1 -1
  60. package/plugins/beta/datasets/dist/umd/im-datasets-ml-adapter.js +2 -0
  61. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +2 -0
  62. package/plugins/beta/datasets/dist/umd/index.js +2 -0
  63. package/plugins/beta/datasets/src/adapters/loadLayerAdapter.js +33 -0
  64. package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +44 -120
  65. package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +145 -245
  66. package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +516 -0
  67. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +209 -0
  68. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +483 -0
  69. package/plugins/beta/datasets/src/api/addDataset.js +2 -5
  70. package/plugins/beta/datasets/src/api/addDataset.test.js +16 -0
  71. package/plugins/beta/datasets/src/api/getOpacity.js +14 -14
  72. package/plugins/beta/datasets/src/api/getOpacity.test.js +72 -0
  73. package/plugins/beta/datasets/src/api/getStyle.js +8 -9
  74. package/plugins/beta/datasets/src/api/getStyle.test.js +42 -0
  75. package/plugins/beta/datasets/src/api/removeDataset.js +7 -7
  76. package/plugins/beta/datasets/src/api/removeDataset.test.js +45 -0
  77. package/plugins/beta/datasets/src/api/setData.js +9 -3
  78. package/plugins/beta/datasets/src/api/setData.test.js +62 -0
  79. package/plugins/beta/datasets/src/api/setDatasetVisibility.js +5 -30
  80. package/plugins/beta/datasets/src/api/setDatasetVisibility.test.js +31 -0
  81. package/plugins/beta/datasets/src/api/setFeatureVisibility.js +9 -18
  82. package/plugins/beta/datasets/src/api/setFeatureVisibility.test.js +74 -0
  83. package/plugins/beta/datasets/src/api/setGlobals.js +20 -0
  84. package/plugins/beta/datasets/src/api/setGlobals.test.js +63 -0
  85. package/plugins/beta/datasets/src/api/setOpacity.js +8 -27
  86. package/plugins/beta/datasets/src/api/setOpacity.test.js +31 -0
  87. package/plugins/beta/datasets/src/api/setStyle.js +5 -21
  88. package/plugins/beta/datasets/src/api/setStyle.test.js +53 -0
  89. package/plugins/beta/datasets/src/components/Key/Key.jsx +51 -0
  90. package/plugins/beta/datasets/src/components/Key/KeyGroupItem.jsx +18 -0
  91. package/plugins/beta/datasets/src/components/Key/KeyItem.jsx +20 -0
  92. package/plugins/beta/datasets/src/components/Key/KeySvg.jsx +22 -0
  93. package/plugins/beta/datasets/src/components/Key/KeySvg.test.jsx +87 -0
  94. package/plugins/beta/datasets/src/components/Key/KeySvgLine.jsx +19 -0
  95. package/plugins/beta/datasets/src/components/Key/KeySvgLine.test.jsx +71 -0
  96. package/plugins/beta/datasets/src/components/{KeySvgPattern.jsx → Key/KeySvgPattern.jsx} +3 -4
  97. package/plugins/beta/datasets/src/components/Key/KeySvgPattern.test.jsx +55 -0
  98. package/plugins/beta/datasets/src/components/Key/KeySvgRect.jsx +22 -0
  99. package/plugins/beta/datasets/src/components/Key/KeySvgRect.test.jsx +85 -0
  100. package/plugins/beta/datasets/src/components/{KeySvgSymbol.jsx → Key/KeySvgSymbol.jsx} +5 -5
  101. package/plugins/beta/datasets/src/components/Key/KeySvgSymbol.test.jsx +80 -0
  102. package/plugins/beta/datasets/src/components/Key/svgProperties.test.js +61 -0
  103. package/plugins/beta/datasets/src/{panels → components/LayersMenu}/Layers.module.scss +15 -11
  104. package/plugins/beta/datasets/src/components/LayersMenu/LayersMenu.jsx +33 -0
  105. package/plugins/beta/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +31 -0
  106. package/plugins/beta/datasets/src/components/LayersMenu/LayersMenuGroupWrapper.jsx +19 -0
  107. package/plugins/beta/datasets/src/datasets.scss +2 -2
  108. package/plugins/beta/datasets/src/fetch/createDynamicSource.js +8 -8
  109. package/plugins/beta/datasets/src/{DatasetsInit.jsx → initialise/DatasetsInit.jsx} +19 -21
  110. package/plugins/beta/datasets/src/{defaults.js → initialise/defaults.js} +17 -2
  111. package/plugins/beta/datasets/src/initialise/defaults.test.js +127 -0
  112. package/plugins/beta/datasets/src/{datasets.js → initialise/initialiseDatasets.js} +30 -26
  113. package/plugins/beta/datasets/src/initialise/initialiseDatasets.test.js +273 -0
  114. package/plugins/beta/datasets/src/manifest.js +8 -6
  115. package/plugins/beta/datasets/src/reducers/__data__/demoDatasets.js +253 -0
  116. package/plugins/beta/datasets/src/reducers/datasetsToMenu.js +83 -0
  117. package/plugins/beta/datasets/src/reducers/datasetsToMenu.test.js +84 -0
  118. package/plugins/beta/datasets/src/reducers/mappedDatasetsReducer.js +41 -0
  119. package/plugins/beta/datasets/src/reducers/mappedDatasetsReducer.test.js +117 -0
  120. package/plugins/beta/datasets/src/reducers/pluginState.js +206 -0
  121. package/plugins/beta/datasets/src/reducers/pluginState.test.js +386 -0
  122. package/plugins/beta/datasets/src/registry/__mocks__/datasetRegistry.js +29 -0
  123. package/plugins/beta/datasets/src/registry/createDataset.js +5 -0
  124. package/plugins/beta/datasets/src/registry/dataset.js +176 -0
  125. package/plugins/beta/datasets/src/registry/dataset.test.js +497 -0
  126. package/plugins/beta/datasets/src/registry/datasetDefinitionCache.js +35 -0
  127. package/plugins/beta/datasets/src/registry/datasetRegistry.js +116 -0
  128. package/plugins/beta/datasets/src/registry/datasetRegistry.test.js +335 -0
  129. package/plugins/beta/datasets/src/registry/dynamicGeoJson.js +17 -0
  130. package/plugins/beta/datasets/src/registry/globalDataset.js +36 -0
  131. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  132. package/plugins/beta/draw-es/src/api/addFeature.js +12 -3
  133. package/plugins/beta/draw-es/src/events.js +8 -3
  134. package/plugins/beta/draw-es/src/events.test.js +2 -0
  135. package/plugins/beta/draw-es/src/graphic.js +26 -2
  136. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  137. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  138. package/plugins/beta/draw-ml/src/DrawInit.jsx +8 -0
  139. package/plugins/beta/draw-ml/src/api/newLine.js +1 -0
  140. package/plugins/beta/draw-ml/src/api/newPolygon.js +1 -0
  141. package/plugins/beta/draw-ml/src/events.js +13 -1
  142. package/plugins/beta/draw-ml/src/index.js +1 -1
  143. package/plugins/beta/draw-ml/src/manifest.js +3 -0
  144. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +21 -12
  145. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +4 -0
  146. package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
  147. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
  148. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +4 -2
  149. package/plugins/beta/map-styles/src/mapStyles.scss +41 -41
  150. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  151. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  152. package/plugins/interact/dist/umd/index.js +1 -1
  153. package/plugins/interact/src/InteractInit.jsx +3 -5
  154. package/plugins/interact/src/InteractInit.test.js +1 -3
  155. package/plugins/interact/src/events.js +2 -29
  156. package/plugins/interact/src/events.test.js +4 -102
  157. package/plugins/interact/src/hooks/useAttachEvents.js +3 -4
  158. package/plugins/interact/src/hooks/useAttachEvents.test.js +1 -3
  159. package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -10
  160. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +5 -10
  161. package/plugins/interact/src/hooks/useHighlightSync.js +1 -10
  162. package/plugins/interact/src/hooks/useHighlightSync.test.js +2 -21
  163. package/plugins/interact/src/hooks/useInteractionHandlers.js +15 -12
  164. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +28 -29
  165. package/plugins/interact/src/manifest.js +0 -35
  166. package/plugins/interact/src/manifest.test.js +3 -43
  167. package/plugins/interact/src/reducer.js +4 -22
  168. package/plugins/interact/src/reducer.test.js +11 -39
  169. package/plugins/search/dist/css/index.css +5 -2
  170. package/plugins/search/src/components/Form/Form.module.scss +5 -2
  171. package/plugins/search/src/search.scss +4 -4
  172. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
  173. package/providers/beta/esri/src/esriProvider.js +4 -0
  174. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  175. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  176. package/providers/beta/openlayers/src/openlayersProvider.js +4 -0
  177. package/providers/beta/openlayers/src/openlayersProvider.test.js +5 -0
  178. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  179. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  180. package/providers/maplibre/src/maplibreProvider.js +6 -4
  181. package/providers/maplibre/src/maplibreProvider.test.js +5 -0
  182. package/providers/maplibre/src/utils/highlightFeatures.js +74 -25
  183. package/providers/maplibre/src/utils/highlightFeatures.test.js +132 -0
  184. package/providers/maplibre/src/utils/patternImages.js +2 -4
  185. package/providers/maplibre/src/utils/symbolImages.js +1 -4
  186. package/rollup.esm.mjs +2 -8
  187. package/src/App/components/CrossHair/CrossHair.module.scss +8 -8
  188. package/src/App/components/MapButton/MapButton.jsx +16 -1
  189. package/src/App/components/MapButton/MapButton.module.scss +12 -1
  190. package/src/App/components/MapButton/MapButton.test.jsx +40 -1
  191. package/src/App/hooks/useContinueEnabledEvaluator.js +31 -0
  192. package/src/App/hooks/useContinueEnabledEvaluator.test.js +118 -0
  193. package/src/App/hooks/useEvaluateProp.js +15 -15
  194. package/src/App/hooks/useEvaluateProp.test.js +80 -76
  195. package/src/App/hooks/useLayoutMeasurements.js +11 -5
  196. package/src/App/hooks/useResizeObserver.js +15 -2
  197. package/src/App/hooks/useResizeObserver.test.js +1 -0
  198. package/src/App/renderer/PluginInits.jsx +2 -0
  199. package/src/App/renderer/mapButtons.js +21 -1
  200. package/src/App/renderer/mapButtons.test.js +46 -1
  201. package/src/App/store/appReducer.js +1 -1
  202. package/src/App/store/appReducer.test.js +37 -0
  203. package/src/InteractiveMap/InteractiveMap.js +14 -4
  204. package/src/InteractiveMap/InteractiveMap.test.js +11 -3
  205. package/src/InteractiveMap/behaviourController.js +3 -1
  206. package/src/InteractiveMap/behaviourController.test.js +6 -3
  207. package/src/InteractiveMap/domStateManager.js +2 -0
  208. package/src/config/appConfig.js +25 -0
  209. package/src/config/appConfig.test.js +50 -0
  210. package/src/config/defaults.js +1 -0
  211. package/src/config/events.js +21 -3
  212. package/src/scss/settings/_dimensions.scss +1 -0
  213. package/src/services/patternRegistry.js +8 -4
  214. package/src/types.js +7 -0
  215. package/src/utils/patternUtils.js +1 -2
  216. package/src/utils/patternUtils.test.js +9 -0
  217. package/webpack.dev.mjs +10 -0
  218. package/webpack.umd.mjs +1 -1
  219. package/docs/assets/images/screens-blue.jpg +0 -0
  220. package/docs/assets/images/screens-white.jpg +0 -0
  221. package/plugins/beta/datasets/dist/adapters/maplibre/esm/im-datasets-ml-adapter.js +0 -1
  222. package/plugins/beta/datasets/dist/adapters/maplibre/esm/index.js +0 -1
  223. package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-maplibre-adapter.js +0 -2
  224. package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-plugin.js +0 -2
  225. package/plugins/beta/datasets/dist/umd/maplibre/index.js +0 -2
  226. package/plugins/beta/datasets/src/adapters/maplibre/index.js +0 -18
  227. package/plugins/beta/datasets/src/adapters/maplibre/layerIds.js +0 -75
  228. package/plugins/beta/datasets/src/adapters/maplibre/patternImages.js +0 -27
  229. package/plugins/beta/datasets/src/adapters/maplibre/symbolImages.js +0 -31
  230. package/plugins/beta/datasets/src/components/KeySvg.jsx +0 -24
  231. package/plugins/beta/datasets/src/components/KeySvgLine.jsx +0 -19
  232. package/plugins/beta/datasets/src/components/KeySvgRect.jsx +0 -22
  233. package/plugins/beta/datasets/src/index.maplibre.umd.js +0 -23
  234. package/plugins/beta/datasets/src/panels/Key.jsx +0 -62
  235. package/plugins/beta/datasets/src/panels/Layers.jsx +0 -141
  236. package/plugins/beta/datasets/src/reducer.js +0 -219
  237. package/plugins/beta/datasets/src/reducers/keyReducer.js +0 -34
  238. package/plugins/beta/datasets/src/utils/filters.js +0 -34
  239. package/plugins/beta/datasets/src/utils/mergeSublayer.js +0 -86
  240. package/plugins/beta/draw-ml/dist/css/index.css +0 -21
  241. /package/plugins/beta/datasets/dist/umd/{maplibre/im-datasets-maplibre-adapter.js.LICENSE.txt → im-datasets-ml-adapter.js.LICENSE.txt} +0 -0
  242. /package/plugins/beta/datasets/dist/umd/{maplibre/im-datasets-plugin.js.LICENSE.txt → im-datasets-plugin.js.LICENSE.txt} +0 -0
  243. /package/plugins/beta/datasets/dist/umd/{maplibre/index.js.LICENSE.txt → index.js.LICENSE.txt} +0 -0
  244. /package/plugins/beta/datasets/src/components/{EmptyKey.jsx → Key/EmptyKey.jsx} +0 -0
  245. /package/plugins/beta/datasets/src/components/{EmptyKey.test.jsx → Key/EmptyKey.test.jsx} +0 -0
  246. /package/plugins/beta/datasets/src/{panels → components/Key}/Key.module.scss +0 -0
  247. /package/plugins/beta/datasets/src/components/{svgProperties.js → Key/svgProperties.js} +0 -0
@@ -0,0 +1,271 @@
1
+ import DemoMapDrawTools from '../../demo/DemoMapDrawTools.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
3
+
4
+ # Draw tools
5
+
6
+ Draw, edit, select and delete polygons and lines using the draw and interact plugins. A single "Draw tools" menu button groups all drawing actions together. The menu items update their enabled state based on whether a drawn feature is selected.
7
+
8
+ :::note
9
+ The draw plugin (`draw-ml`) is currently in beta.
10
+ :::
11
+
12
+ <DemoMapDrawTools />
13
+
14
+ <CodeTabs tabs={[
15
+ {
16
+ label: 'ESM',
17
+ language: 'js',
18
+ code: `
19
+ import InteractiveMap from '@defra/interactive-map'
20
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
21
+ import createInteractPlugin from '@defra/interactive-map/plugins/interact'
22
+ import createDrawPlugin from '@defra/interactive-map/plugins/draw-ml'
23
+
24
+ const DRAW_LAYERS = ['fill-inactive.cold', 'stroke-inactive.cold']
25
+
26
+ const interactPlugin = createInteractPlugin({
27
+ layers: [
28
+ { layerId: 'fill-inactive.cold', idProperty: 'id' },
29
+ { layerId: 'stroke-inactive.cold', idProperty: 'id' }
30
+ ],
31
+ interactionModes: ['selectFeature'],
32
+ multiSelect: true,
33
+ deselectOnClickOutside: true
34
+ })
35
+
36
+ const drawPlugin = createDrawPlugin()
37
+
38
+ const interactiveMap = new InteractiveMap('my-map', {
39
+ behaviour: 'inline',
40
+ mapProvider: maplibreProvider(),
41
+ mapStyle: {
42
+ url: 'https://your-tile-url/style.json',
43
+ attribution: 'Your tile attribution'
44
+ },
45
+ center: [-0.1276, 51.5074],
46
+ zoom: 12,
47
+ containerHeight: '516px',
48
+ plugins: [interactPlugin, drawPlugin]
49
+ })
50
+
51
+ let selectedFeatureIds = []
52
+
53
+ interactiveMap.on('map:ready', () => {
54
+ interactPlugin.enable()
55
+
56
+ interactiveMap.addButton('drawTools', {
57
+ label: 'Draw tools',
58
+ mobile: { slot: 'bottom-right' },
59
+ tablet: { slot: 'top-middle' },
60
+ desktop: { slot: 'top-middle' },
61
+ menuItems: [
62
+ {
63
+ id: 'drawPolygon',
64
+ label: 'Draw polygon',
65
+ iconSvgContent: '<path d="M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10"/><path d="M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z"/>',
66
+ onClick: () => {
67
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
68
+ drawPlugin.newPolygon(crypto.randomUUID())
69
+ }
70
+ },
71
+ {
72
+ id: 'drawLine',
73
+ label: 'Draw line',
74
+ iconSvgContent: '<path d="M5.706 16.294L16.294 5.706"/><path d="M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z"/>',
75
+ onClick: () => {
76
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
77
+ drawPlugin.newLine(crypto.randomUUID())
78
+ }
79
+ },
80
+ {
81
+ id: 'editFeature',
82
+ label: 'Edit feature',
83
+ iconSvgContent: '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',
84
+ isDisabled: true,
85
+ onClick: () => {
86
+ if (!drawPlugin.editFeature(selectedFeatureIds[0])) return
87
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
88
+ interactPlugin.disable()
89
+ }
90
+ },
91
+ {
92
+ id: 'deleteFeature',
93
+ label: 'Delete feature',
94
+ iconSvgContent: '<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',
95
+ isDisabled: true,
96
+ onClick: () => {
97
+ drawPlugin.deleteFeature(selectedFeatureIds)
98
+ interactPlugin.clear()
99
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
100
+ interactiveMap.toggleButtonState('drawPolygon', 'disabled', false)
101
+ interactiveMap.toggleButtonState('drawLine', 'disabled', false)
102
+ interactiveMap.toggleButtonState('editFeature', 'disabled', true)
103
+ interactiveMap.toggleButtonState('deleteFeature', 'disabled', true)
104
+ }
105
+ }
106
+ ]
107
+ })
108
+ })
109
+
110
+ interactiveMap.on('draw:started', () => {
111
+ interactPlugin.disable()
112
+ })
113
+
114
+ interactiveMap.on('draw:created', () => {
115
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
116
+ interactPlugin.enable()
117
+ })
118
+
119
+ interactiveMap.on('draw:edited', () => {
120
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
121
+ interactPlugin.enable()
122
+ })
123
+
124
+ interactiveMap.on('draw:cancelled', () => {
125
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
126
+ interactPlugin.enable()
127
+ })
128
+
129
+ interactiveMap.on('interact:selectionchange', (e) => {
130
+ const singleFeature = e.selectedFeatures.length === 1
131
+ const anyFeature = e.selectedFeatures.length > 0
132
+ const isDrawFeature = singleFeature && DRAW_LAYERS.includes(e.selectedFeatures[0].layerId)
133
+ const allDrawFeatures = anyFeature && e.selectedFeatures.every(f => DRAW_LAYERS.includes(f.layerId))
134
+ selectedFeatureIds = e.selectedFeatures.map(f => f.featureId)
135
+ interactiveMap.toggleButtonState('drawPolygon', 'disabled', singleFeature)
136
+ interactiveMap.toggleButtonState('drawLine', 'disabled', singleFeature)
137
+ interactiveMap.toggleButtonState('editFeature', 'disabled', !isDrawFeature)
138
+ interactiveMap.toggleButtonState('deleteFeature', 'disabled', !allDrawFeatures)
139
+ })
140
+ `
141
+ },
142
+ {
143
+ label: 'UMD',
144
+ language: 'html',
145
+ code: `
146
+ <script src="/your-assets-path/interactive-map/index.js"></script>
147
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
148
+ <script src="/your-assets-path/interact-plugin/index.js"></script>
149
+ <script src="/your-assets-path/draw-ml-plugin/index.js"></script>
150
+
151
+ <script>
152
+ const DRAW_LAYERS = ['fill-inactive.cold', 'stroke-inactive.cold']
153
+
154
+ const interactPlugin = defra.interactPlugin({
155
+ layers: [
156
+ { layerId: 'fill-inactive.cold', idProperty: 'id' },
157
+ { layerId: 'stroke-inactive.cold', idProperty: 'id' }
158
+ ],
159
+ interactionModes: ['selectFeature'],
160
+ multiSelect: true,
161
+ deselectOnClickOutside: true
162
+ })
163
+
164
+ const drawPlugin = defra.drawMLPlugin()
165
+
166
+ const interactiveMap = new defra.InteractiveMap('my-map', {
167
+ behaviour: 'inline',
168
+ mapProvider: defra.maplibreProvider(),
169
+ mapStyle: {
170
+ url: 'https://your-tile-url/style.json',
171
+ attribution: 'Your tile attribution'
172
+ },
173
+ center: [-0.1276, 51.5074],
174
+ zoom: 12,
175
+ containerHeight: '516px',
176
+ plugins: [interactPlugin, drawPlugin]
177
+ })
178
+
179
+ let selectedFeatureIds = []
180
+
181
+ interactiveMap.on('map:ready', function () {
182
+ interactPlugin.enable()
183
+
184
+ interactiveMap.addButton('drawTools', {
185
+ label: 'Draw tools',
186
+ mobile: { slot: 'bottom-right' },
187
+ tablet: { slot: 'top-middle' },
188
+ desktop: { slot: 'top-middle' },
189
+ menuItems: [
190
+ {
191
+ id: 'drawPolygon',
192
+ label: 'Draw polygon',
193
+ iconSvgContent: '<path d="M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10"/><path d="M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z"/>',
194
+ onClick: function () {
195
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
196
+ drawPlugin.newPolygon(crypto.randomUUID())
197
+ }
198
+ },
199
+ {
200
+ id: 'drawLine',
201
+ label: 'Draw line',
202
+ iconSvgContent: '<path d="M5.706 16.294L16.294 5.706"/><path d="M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z"/>',
203
+ onClick: function () {
204
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
205
+ drawPlugin.newLine(crypto.randomUUID())
206
+ }
207
+ },
208
+ {
209
+ id: 'editFeature',
210
+ label: 'Edit feature',
211
+ iconSvgContent: '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',
212
+ isDisabled: true,
213
+ onClick: function () {
214
+ if (!drawPlugin.editFeature(selectedFeatureIds[0])) return
215
+ interactiveMap.toggleButtonState('drawTools', 'hidden', true)
216
+ interactPlugin.disable()
217
+ }
218
+ },
219
+ {
220
+ id: 'deleteFeature',
221
+ label: 'Delete feature',
222
+ iconSvgContent: '<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',
223
+ isDisabled: true,
224
+ onClick: function () {
225
+ drawPlugin.deleteFeature(selectedFeatureIds)
226
+ interactPlugin.clear()
227
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
228
+ interactiveMap.toggleButtonState('drawPolygon', 'disabled', false)
229
+ interactiveMap.toggleButtonState('drawLine', 'disabled', false)
230
+ interactiveMap.toggleButtonState('editFeature', 'disabled', true)
231
+ interactiveMap.toggleButtonState('deleteFeature', 'disabled', true)
232
+ }
233
+ }
234
+ ]
235
+ })
236
+ })
237
+
238
+ interactiveMap.on('draw:started', function () {
239
+ interactPlugin.disable()
240
+ })
241
+
242
+ interactiveMap.on('draw:created', function () {
243
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
244
+ interactPlugin.enable()
245
+ })
246
+
247
+ interactiveMap.on('draw:edited', function () {
248
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
249
+ interactPlugin.enable()
250
+ })
251
+
252
+ interactiveMap.on('draw:cancelled', function () {
253
+ interactiveMap.toggleButtonState('drawTools', 'hidden', false)
254
+ interactPlugin.enable()
255
+ })
256
+
257
+ interactiveMap.on('interact:selectionchange', function (e) {
258
+ var singleFeature = e.selectedFeatures.length === 1
259
+ var anyFeature = e.selectedFeatures.length > 0
260
+ var isDrawFeature = singleFeature && DRAW_LAYERS.includes(e.selectedFeatures[0].layerId)
261
+ var allDrawFeatures = anyFeature && e.selectedFeatures.every(function (f) { return DRAW_LAYERS.includes(f.layerId) })
262
+ selectedFeatureIds = e.selectedFeatures.map(function (f) { return f.featureId })
263
+ interactiveMap.toggleButtonState('drawPolygon', 'disabled', singleFeature)
264
+ interactiveMap.toggleButtonState('drawLine', 'disabled', singleFeature)
265
+ interactiveMap.toggleButtonState('editFeature', 'disabled', !isDrawFeature)
266
+ interactiveMap.toggleButtonState('deleteFeature', 'disabled', !allDrawFeatures)
267
+ })
268
+ </script>
269
+ `
270
+ }
271
+ ]} />
@@ -2,52 +2,136 @@ import useBaseUrl from '@docusaurus/useBaseUrl'
2
2
  import basicMapImg from '../assets/images/basic-map.jpg'
3
3
  import buttonFirstImg from '../assets/images/button-first.jpg'
4
4
  import markerPanelImg from '../assets/images/marker-panel.jpg'
5
+ import placeMarkerImg from '../assets/images/place-marker.jpg'
5
6
  import toggleMarkerLabelImg from '../assets/images/toggle-marker-label.jpg'
7
+ import searchImg from '../assets/images/search.jpg'
8
+ import selectFeatureImg from '../assets/images/select-feature.jpg'
9
+ import styleSwitcherImg from '../assets/images/style-switcher.jpg'
10
+ import drawImg from '../assets/images/draw.jpg'
11
+ import addSymbolsImg from '../assets/images/add-symbols.jpg'
12
+ import addPolygonsImg from '../assets/images/add-polygons.jpg'
6
13
 
7
14
  export function ExampleCards() {
8
15
  const basicHref = useBaseUrl('/examples/basic-map')
9
16
  const buttonHref = useBaseUrl('/examples/button-map')
10
17
  const interactHref = useBaseUrl('/examples/add-marker-with-panel')
11
18
  const toggleMarkerLabelHref = useBaseUrl('/examples/toggle-marker-label')
19
+ const searchControlHref = useBaseUrl('/examples/search-control')
20
+ const selectFeatureHref = useBaseUrl('/examples/select-feature')
21
+ const styleSwitcherHref = useBaseUrl('/examples/style-switcher')
22
+ const drawHref = useBaseUrl('/examples/draw-tools')
23
+ const placeMarkerHref = useBaseUrl('/examples/place-marker')
24
+ const datasetsHref = useBaseUrl('/examples/add-symbols')
25
+ const polygonsHref = useBaseUrl('/examples/add-polygons')
12
26
 
13
27
  return (
14
- <div className='govuk-grid-row'>
15
- <div className='govuk-grid-column-one-half'>
28
+ <div className='govuk-grid-row app-example-cards'>
29
+ <div className='govuk-grid-column-one-third'>
16
30
  <div className='app-example-card'>
17
31
  <img src={basicMapImg} alt='' />
18
32
  <div className='app-example-card__body'>
19
- <h2 className='govuk-heading-m'>
33
+ <h2 className='govuk-heading-s'>
20
34
  <a href={basicHref}>Basic map</a>
21
35
  </h2>
22
36
  </div>
23
37
  </div>
24
38
  </div>
25
- <div className='govuk-grid-column-one-half'>
39
+ <div className='govuk-grid-column-one-third'>
26
40
  <div className='app-example-card'>
27
41
  <img src={buttonFirstImg} alt='' />
28
42
  <div className='app-example-card__body'>
29
- <h2 className='govuk-heading-m'>
43
+ <h2 className='govuk-heading-s'>
30
44
  <a href={buttonHref}>Button-triggered map</a>
31
45
  </h2>
32
46
  </div>
33
47
  </div>
34
48
  </div>
35
- <div className='govuk-grid-column-one-half'>
49
+ <div className='govuk-grid-column-one-third'>
36
50
  <div className='app-example-card'>
37
51
  <img src={markerPanelImg} alt='' />
38
52
  <div className='app-example-card__body'>
39
- <h2 className='govuk-heading-m'>
40
- <a href={interactHref}>Add a marker with a panel</a>
53
+ <h2 className='govuk-heading-s'>
54
+ <a href={interactHref}>Map with marker and panel</a>
41
55
  </h2>
42
56
  </div>
43
57
  </div>
44
58
  </div>
45
- <div className='govuk-grid-column-one-half'>
59
+ <div className='govuk-grid-column-one-third'>
46
60
  <div className='app-example-card'>
47
61
  <img src={toggleMarkerLabelImg} alt='' />
48
62
  <div className='app-example-card__body'>
49
- <h2 className='govuk-heading-m'>
50
- <a href={toggleMarkerLabelHref}>Toggle marker label on click</a>
63
+ <h2 className='govuk-heading-s'>
64
+ <a href={toggleMarkerLabelHref}>Toggle marker label</a>
65
+ </h2>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <div className='govuk-grid-column-one-third'>
70
+ <div className='app-example-card'>
71
+ <img src={placeMarkerImg} alt='' />
72
+ <div className='app-example-card__body'>
73
+ <h2 className='govuk-heading-s'>
74
+ <a href={placeMarkerHref}>Place a marker to continue</a>
75
+ </h2>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ <div className='govuk-grid-column-one-third'>
80
+ <div className='app-example-card'>
81
+ <img src={searchImg} alt='' />
82
+ <div className='app-example-card__body'>
83
+ <h2 className='govuk-heading-s'>
84
+ <a href={searchControlHref}>Add a search control</a>
85
+ </h2>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ <div className='govuk-grid-column-one-third'>
90
+ <div className='app-example-card'>
91
+ <img src={selectFeatureImg} alt='' />
92
+ <div className='app-example-card__body'>
93
+ <h2 className='govuk-heading-s'>
94
+ <a href={selectFeatureHref}>Select a feature</a>
95
+ </h2>
96
+ </div>
97
+ </div>
98
+ </div>
99
+ <div className='govuk-grid-column-one-third'>
100
+ <div className='app-example-card'>
101
+ <img src={styleSwitcherImg} alt='' />
102
+ <div className='app-example-card__body'>
103
+ <h2 className='govuk-heading-s'>
104
+ <a href={styleSwitcherHref}>Change map style</a>
105
+ </h2>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ <div className='govuk-grid-column-one-third'>
110
+ <div className='app-example-card'>
111
+ <img src={drawImg} alt='' />
112
+ <div className='app-example-card__body'>
113
+ <h2 className='govuk-heading-s'>
114
+ <a href={drawHref}>Draw tools</a>
115
+ </h2>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div className='govuk-grid-column-one-third'>
120
+ <div className='app-example-card'>
121
+ <img src={addSymbolsImg} alt='' />
122
+ <div className='app-example-card__body'>
123
+ <h2 className='govuk-heading-s'>
124
+ <a href={datasetsHref}>Add symbols</a>
125
+ </h2>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ <div className='govuk-grid-column-one-third'>
130
+ <div className='app-example-card'>
131
+ <img src={addPolygonsImg} alt='' />
132
+ <div className='app-example-card__body'>
133
+ <h2 className='govuk-heading-s'>
134
+ <a href={polygonsHref}>Add polygons</a>
51
135
  </h2>
52
136
  </div>
53
137
  </div>
@@ -0,0 +1,151 @@
1
+ import DemoMapPlaceMarker from '../../demo/DemoMapPlaceMarker.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
3
+
4
+ # Place a marker to continue
5
+
6
+ Use the interact plugin's `placeMarker` mode to let users drop a location pin on the map before continuing a journey.
7
+
8
+ Two patterns work together in this example:
9
+
10
+ - **Hybrid behaviour with built-in back and continue** — on mobile the map opens fullscreen and the `backAndContinue` option renders Back and Continue buttons inside the map. The Continue button is enabled declaratively via `continueEnabledWhen` once a marker has been placed.
11
+ - **External Continue button for inline** — when the map is inline (tablet/desktop), a Continue button sits outside the map container. It uses `app:opened`, `app:closed`, and `app:fullscreenchange` to show and hide in sync with the map's display mode, and `interact:markerchange` to enable once a marker is placed.
12
+
13
+ <DemoMapPlaceMarker />
14
+
15
+ <CodeTabs tabs={[
16
+ {
17
+ label: 'ESM',
18
+ language: 'js',
19
+ code: `
20
+ import InteractiveMap from '@defra/interactive-map'
21
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
22
+ import createInteractPlugin from '@defra/interactive-map/plugins/interact'
23
+
24
+ const interactPlugin = createInteractPlugin({
25
+ interactionModes: ['placeMarker']
26
+ })
27
+
28
+ const map = new InteractiveMap('my-map', {
29
+ behaviour: 'hybrid',
30
+ mapProvider: maplibreProvider(),
31
+ mapStyle: {
32
+ url: 'https://your-tile-url/style.json',
33
+ attribution: 'Your tile attribution'
34
+ },
35
+ center: [-0.1276, 51.5074],
36
+ zoom: 12,
37
+ containerHeight: '516px',
38
+ plugins: [interactPlugin],
39
+ // Back and Continue buttons shown inside the map when fullscreen (mobile)
40
+ backAndContinue: {
41
+ backLabel: 'Back',
42
+ continueLabel: 'Continue',
43
+ continueEnabledWhen: ({ mapState }) =>
44
+ mapState.markers.items.some(m => m.id === 'location')
45
+ }
46
+ })
47
+
48
+ map.on('map:ready', () => {
49
+ interactPlugin.enable()
50
+ })
51
+
52
+ // Fired when the built-in Continue button is clicked (mobile/fullscreen)
53
+ map.on('app:continue', ({ mapState }) => {
54
+ const marker = mapState.markers.items.find(m => m.id === 'location')
55
+ // navigate to next step with marker.coords
56
+ })
57
+
58
+ // --- External Continue button for inline (tablet/desktop) ---
59
+
60
+ const continueBtn = document.getElementById('continue-btn')
61
+ const externalButtons = document.getElementById('external-buttons')
62
+
63
+ // Show/hide external buttons based on whether the map is inline or fullscreen.
64
+ // app:opened fires on first load and when the map is shown after being hidden.
65
+ // app:fullscreenchange fires when the viewport resizes while the map is already visible.
66
+ const setInline = (isFullscreen) => {
67
+ externalButtons.hidden = isFullscreen
68
+ }
69
+
70
+ map.on('app:opened', ({ isFullscreen }) => { setInline(isFullscreen) })
71
+ map.on('app:closed', () => { externalButtons.hidden = true })
72
+ map.on('app:fullscreenchange', ({ isFullscreen }) => { setInline(isFullscreen) })
73
+
74
+ map.on('interact:markerchange', () => {
75
+ continueBtn.disabled = false
76
+ })
77
+
78
+ continueBtn.addEventListener('click', () => {
79
+ // navigate to next step
80
+ })
81
+ `
82
+ },
83
+ {
84
+ label: 'UMD',
85
+ language: 'html',
86
+ code: `
87
+ <script src="/your-assets-path/interactive-map/index.js"></script>
88
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
89
+ <script src="/your-assets-path/interact-plugin/index.js"></script>
90
+
91
+ <div id="my-map"></div>
92
+ <div id="external-buttons" hidden>
93
+ <button class="govuk-button" id="continue-btn" disabled>Continue</button>
94
+ </div>
95
+
96
+ <script>
97
+ var interactPlugin = defra.interactPlugin({
98
+ interactionModes: ['placeMarker']
99
+ })
100
+
101
+ var map = new defra.InteractiveMap('my-map', {
102
+ behaviour: 'hybrid',
103
+ mapProvider: defra.maplibreProvider(),
104
+ mapStyle: {
105
+ url: 'https://your-tile-url/style.json',
106
+ attribution: 'Your tile attribution'
107
+ },
108
+ center: [-0.1276, 51.5074],
109
+ zoom: 12,
110
+ containerHeight: '516px',
111
+ plugins: [interactPlugin],
112
+ backAndContinue: {
113
+ backLabel: 'Back',
114
+ continueLabel: 'Continue',
115
+ continueEnabledWhen: function (context) {
116
+ return context.mapState.markers.items.some(function (m) { return m.id === 'location' })
117
+ }
118
+ }
119
+ })
120
+
121
+ map.on('map:ready', function () {
122
+ interactPlugin.enable()
123
+ })
124
+
125
+ map.on('app:continue', function (context) {
126
+ var marker = context.mapState.markers.items.find(function (m) { return m.id === 'location' })
127
+ // navigate to next step with marker.coords
128
+ })
129
+
130
+ var continueBtn = document.getElementById('continue-btn')
131
+ var externalButtons = document.getElementById('external-buttons')
132
+
133
+ function setInline(isFullscreen) {
134
+ externalButtons.hidden = isFullscreen
135
+ }
136
+
137
+ map.on('app:opened', function (e) { setInline(e.isFullscreen) })
138
+ map.on('app:closed', function () { externalButtons.hidden = true })
139
+ map.on('app:fullscreenchange', function (e) { setInline(e.isFullscreen) })
140
+
141
+ map.on('interact:markerchange', function () {
142
+ continueBtn.disabled = false
143
+ })
144
+
145
+ continueBtn.addEventListener('click', function () {
146
+ // navigate to next step
147
+ })
148
+ </script>
149
+ `
150
+ }
151
+ ]} />
@@ -0,0 +1,71 @@
1
+ import DemoMapSearchNominatim from '../../demo/DemoMapSearchNominatim.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
3
+
4
+ # Add a search control
5
+
6
+ Add a search control using the built-in OS Names API integration.
7
+
8
+ :::note
9
+ The live demo below uses Nominatim (no API key required) — the code example uses OS Names, so results may differ slightly. Embedding the key in the URL is the simplest approach for prototyping; for production, `transformRequest` can be used to inject auth headers, or you may need to route requests through your own server-side proxy.
10
+ :::
11
+
12
+ <DemoMapSearchNominatim />
13
+
14
+ <CodeTabs tabs={[
15
+ {
16
+ label: 'ESM',
17
+ language: 'js',
18
+ code: `
19
+ import InteractiveMap from '@defra/interactive-map'
20
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
21
+ import createSearchPlugin from '@defra/interactive-map/plugins/search'
22
+
23
+ const searchPlugin = createSearchPlugin({
24
+ osNamesURL: 'https://api.os.uk/search/names/v1/find?query={query}&key=YOUR_API_KEY',
25
+ width: '300px'
26
+ })
27
+
28
+ new InteractiveMap('my-map', {
29
+ behaviour: 'inline',
30
+ mapProvider: maplibreProvider(),
31
+ mapStyle: {
32
+ url: 'https://your-tile-url/style.json',
33
+ attribution: 'Your tile attribution'
34
+ },
35
+ center: [-1.6, 53.1],
36
+ zoom: 6,
37
+ containerHeight: '516px',
38
+ plugins: [searchPlugin]
39
+ })
40
+ `
41
+ },
42
+ {
43
+ label: 'UMD',
44
+ language: 'html',
45
+ code: `
46
+ <script src="/your-assets-path/interactive-map/index.js"></script>
47
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
48
+ <script src="/your-assets-path/search-plugin/index.js"></script>
49
+
50
+ <script>
51
+ const searchPlugin = defra.searchPlugin({
52
+ osNamesURL: 'https://api.os.uk/search/names/v1/find?query={query}&key=YOUR_API_KEY',
53
+ width: '300px'
54
+ })
55
+
56
+ new defra.InteractiveMap('my-map', {
57
+ behaviour: 'inline',
58
+ mapProvider: defra.maplibreProvider(),
59
+ mapStyle: {
60
+ url: 'https://your-tile-url/style.json',
61
+ attribution: 'Your tile attribution'
62
+ },
63
+ center: [-1.6, 53.1],
64
+ zoom: 6,
65
+ containerHeight: '516px',
66
+ plugins: [searchPlugin]
67
+ })
68
+ </script>
69
+ `
70
+ }
71
+ ]} />