@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
@@ -1,7 +1,7 @@
1
1
  import DemoMapMarkerPanel from '../../demo/DemoMapMarkerPanel.js'
2
2
  import CodeTabs from '../../demo/js/codeTabs.js'
3
3
 
4
- # Add a marker with a panel
4
+ # Map with marker and panel
5
5
 
6
6
  Add markers to the map and allow users to select them. Selecting a marker fires the `interact:selectionchange` event, which can be used to show a panel with relevant information.
7
7
 
@@ -29,7 +29,7 @@ Add markers to the map and allow users to select them. Selecting a marker fires
29
29
  },
30
30
  center: [-2.96, 54.43],
31
31
  zoom: 15,
32
- containerHeight: '500px',
32
+ containerHeight: '516px',
33
33
  plugins: [interactPlugin]
34
34
  })
35
35
 
@@ -85,7 +85,7 @@ Add markers to the map and allow users to select them. Selecting a marker fires
85
85
  },
86
86
  center: [-2.96, 54.43],
87
87
  zoom: 15,
88
- containerHeight: '500px',
88
+ containerHeight: '516px',
89
89
  plugins: [interactPlugin]
90
90
  })
91
91
 
@@ -0,0 +1,225 @@
1
+ import DemoMapPolygons from '../../demo/DemoMapPolygons.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
3
+
4
+ # Add polygons
5
+
6
+ Use the datasets plugin to overlay GeoJSON polygon data on your map. This example shows a set of field parcels styled with a fill colour and border.
7
+
8
+ <DemoMapPolygons />
9
+
10
+ <CodeTabs tabs={[
11
+ {
12
+ label: 'ESM',
13
+ language: 'js',
14
+ code: `
15
+ import InteractiveMap from '@defra/interactive-map'
16
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
17
+ import createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'
18
+
19
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
20
+ const geojson = {
21
+ type: 'FeatureCollection',
22
+ features: [{
23
+ type: 'Feature',
24
+ id: 1,
25
+ properties: { name: 'Feature 1', land_use: 'Permanent grassland' },
26
+ geometry: { type: 'Polygon', coordinates: [[[-2.4691585,54.5552164],[-2.4692202,54.5553906],[-2.4690646,54.5554155],[-2.4690002,54.5555088],[-2.4690297,54.5556690],[-2.4690995,54.5557919],[-2.4669269,54.5566971],[-2.4662375,54.5562819],[-2.4637780,54.5574391],[-2.4628580,54.5568169],[-2.4607612,54.5560985],[-2.4608248,54.5560719],[-2.4611789,54.5558914],[-2.4613774,54.5558168],[-2.4615973,54.5557577],[-2.4617475,54.5557297],[-2.4618816,54.5556519],[-2.4620104,54.5556115],[-2.4624771,54.5555275],[-2.4627131,54.5555150],[-2.4628741,54.5554839],[-2.4630082,54.5554404],[-2.4632335,54.5553346],[-2.4633944,54.5552164],[-2.4634749,54.5551106],[-2.4635178,54.5550235],[-2.4635285,54.5548213],[-2.4635768,54.5546346],[-2.4635875,54.5544884],[-2.4636090,54.5544075],[-2.4636465,54.5543515],[-2.4636573,54.5542769],[-2.4636358,54.5541804],[-2.4637377,54.5540155],[-2.4639094,54.5538724],[-2.4643493,54.5535831],[-2.4645370,54.5535084],[-2.4647141,54.5534804],[-2.4648052,54.5534836],[-2.4648213,54.5535116],[-2.4648750,54.5535396],[-2.4650842,54.5535893],[-2.4652451,54.5536516],[-2.4652719,54.5536796],[-2.4653900,54.5537355],[-2.4655455,54.5537853],[-2.4658459,54.5539502],[-2.4663556,54.5542738],[-2.4668008,54.5545164],[-2.4668330,54.5545506],[-2.4668437,54.5546782],[-2.4668598,54.5547031],[-2.4670798,54.5548306],[-2.4671817,54.5549053],[-2.4674177,54.5549364],[-2.4677664,54.5550484],[-2.4681956,54.5551448],[-2.4684101,54.5551759],[-2.4691129,54.5552195],[-2.4691585,54.5552164]]] }
27
+ }, {
28
+ type: 'Feature',
29
+ id: 2,
30
+ properties: { name: 'Feature 2', land_use: 'Arable' },
31
+ geometry: { type: 'Polygon', coordinates: [[[-2.4611682,54.5562375],[-2.4628580,54.5568161],[-2.4636841,54.5573753],[-2.4637793,54.5574398],[-2.4641401,54.5576751],[-2.4642567,54.5577999],[-2.4641307,54.5578823],[-2.4636841,54.5582502],[-2.4624221,54.5592884],[-2.4623376,54.5592534],[-2.4615370,54.5586429],[-2.4611869,54.5582852],[-2.4605258,54.5581071],[-2.4598472,54.5578186],[-2.4611682,54.5562375]]] }
32
+ }, {
33
+ type: 'Feature',
34
+ id: 3,
35
+ properties: { name: 'Feature 3', land_use: 'Arable' },
36
+ geometry: { type: 'Polygon', coordinates: [[[-2.4598472,54.5578186],[-2.4605258,54.5581067],[-2.4611869,54.5582852],[-2.4615376,54.5586433],[-2.4623108,54.5592332],[-2.4623376,54.5592534],[-2.4624221,54.5592884],[-2.4623108,54.5594120],[-2.4616731,54.5601189],[-2.4586053,54.5601189],[-2.4584410,54.5600299],[-2.4580038,54.5596574],[-2.4581815,54.5593953],[-2.4585778,54.5590702],[-2.4587287,54.5589353],[-2.4589198,54.5586736],[-2.4591116,54.5582136],[-2.4598472,54.5578186]]] }
37
+ }, {
38
+ type: 'Feature',
39
+ id: 4,
40
+ properties: { name: 'Feature 4', land_use: 'Permanent grassland' },
41
+ geometry: { type: 'Polygon', coordinates: [[[-2.4633756,54.5612877],[-2.4613908,54.5604315],[-2.4624221,54.5592884],[-2.4641307,54.5578823],[-2.4642567,54.5577999],[-2.4653631,54.5591733],[-2.4659613,54.5597013],[-2.4633756,54.5612877]]] }
42
+ }, {
43
+ type: 'Feature',
44
+ id: 5,
45
+ properties: { name: 'Feature 5', land_use: 'Arable' },
46
+ geometry: { type: 'Polygon', coordinates: [[[-2.4678040,54.5590679],[-2.4661879,54.5595952],[-2.4659613,54.5597013],[-2.4653638,54.5591737],[-2.4642567,54.5577999],[-2.4641401,54.5576751],[-2.4637793,54.5574398],[-2.4662369,54.5562822],[-2.4669282,54.5566975],[-2.4678040,54.5563320],[-2.4678040,54.5590679]]] }
47
+ }, {
48
+ type: 'Feature',
49
+ id: 6,
50
+ properties: { name: 'Feature 6', land_use: 'Permanent grassland' },
51
+ geometry: { type: 'Polygon', coordinates: [[[-2.4669316,54.5603767],[-2.4676430,54.5613102],[-2.4673292,54.5614556],[-2.4671616,54.5617468],[-2.4658446,54.5625528],[-2.4651546,54.5621528],[-2.4639215,54.5633040],[-2.4633146,54.5633040],[-2.4628372,54.5630921],[-2.4631195,54.5628195],[-2.4643741,54.5618374],[-2.4665071,54.5604793],[-2.4667056,54.5604187],[-2.4669316,54.5603767]]] }
52
+ }, {
53
+ type: 'Feature',
54
+ id: 7,
55
+ properties: { name: 'Feature 7', land_use: 'Woodland' },
56
+ geometry: { type: 'Polygon', coordinates: [[[-2.4599129,54.5564203],[-2.4599773,54.5565478],[-2.4599773,54.5565852],[-2.4599344,54.5566256],[-2.4596876,54.5566069],[-2.4594945,54.5566132],[-2.4593657,54.5566505],[-2.4592584,54.5567158],[-2.4592048,54.5567780],[-2.4591780,54.5568496],[-2.4591887,54.5569616],[-2.4591297,54.5570829],[-2.4590009,54.5572726],[-2.4589419,54.5573162],[-2.4588561,54.5574686],[-2.4587435,54.5575588],[-2.4586684,54.5575837],[-2.4585879,54.5575962],[-2.4584001,54.5575837],[-2.4583304,54.5575899],[-2.4580836,54.5576397],[-2.4579817,54.5576895],[-2.4579227,54.5576988],[-2.4578154,54.5576988],[-2.4576384,54.5576739],[-2.4574614,54.5576739],[-2.4573044,54.5577050],[-2.4563093,54.5573092],[-2.4563871,54.5569849],[-2.4564891,54.5560664],[-2.4565601,54.5559039],[-2.4567747,54.5559412],[-2.4571985,54.5559817],[-2.4573219,54.5560097],[-2.4576116,54.5560936],[-2.4582446,54.5562181],[-2.4584913,54.5562959],[-2.4590331,54.5563705],[-2.4599129,54.5564203]]] }
57
+ }]
58
+ }
59
+
60
+ const datasetsPlugin = createDatasetsPlugin({
61
+ datasets: [{
62
+ id: 'field-parcels',
63
+ label: 'Field parcels',
64
+ geojson: geojson,
65
+ minZoom: 10,
66
+ maxZoom: 24,
67
+ showInKey: true,
68
+ showInMenu: true,
69
+ sublayers: [{
70
+ id: 'arable',
71
+ label: 'Arable',
72
+ filter: ['==', ['get', 'land_use'], 'Arable'],
73
+ style: {
74
+ stroke: '#6D4C41',
75
+ fillPattern: 'horizontal-hatch',
76
+ fillPatternForegroundColor: '#6D4C41',
77
+ fillPatternBackgroundColor: 'transparent'
78
+ }
79
+ }, {
80
+ id: 'permanent-grassland',
81
+ label: 'Permanent grassland',
82
+ filter: ['==', ['get', 'land_use'], 'Permanent grassland'],
83
+ style: {
84
+ stroke: '#00897B',
85
+ fillPattern: 'diagonal-cross-hatch',
86
+ fillPatternForegroundColor: '#00897B',
87
+ fillPatternBackgroundColor: 'transparent'
88
+ }
89
+ }, {
90
+ id: 'woodland',
91
+ label: 'Woodland',
92
+ filter: ['==', ['get', 'land_use'], 'Woodland'],
93
+ style: {
94
+ stroke: '#2E7D32',
95
+ fillPattern: 'dot',
96
+ fillPatternForegroundColor: '#2E7D32',
97
+ fillPatternBackgroundColor: 'transparent'
98
+ }
99
+ }]
100
+ }]
101
+ })
102
+
103
+ new InteractiveMap('my-map', {
104
+ behaviour: 'inline',
105
+ mapProvider: maplibreProvider(),
106
+ mapStyle: {
107
+ url: 'https://your-tile-url/style.json',
108
+ attribution: 'Your tile attribution'
109
+ },
110
+ center: [-2.464, 54.558],
111
+ zoom: 14,
112
+ containerHeight: '516px',
113
+ plugins: [datasetsPlugin]
114
+ })
115
+ `
116
+ },
117
+ {
118
+ label: 'UMD',
119
+ language: 'html',
120
+ code: `
121
+ <script src="/your-assets-path/interactive-map/index.js"></script>
122
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
123
+ <script src="/your-assets-path/datasets-plugin/index.js"></script>
124
+
125
+ <script>
126
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
127
+ const geojson = {
128
+ type: 'FeatureCollection',
129
+ features: [{
130
+ type: 'Feature',
131
+ id: 1,
132
+ properties: { name: 'Feature 1', land_use: 'Permanent grassland' },
133
+ geometry: { type: 'Polygon', coordinates: [[[-2.4691585,54.5552164],[-2.4692202,54.5553906],[-2.4690646,54.5554155],[-2.4690002,54.5555088],[-2.4690297,54.5556690],[-2.4690995,54.5557919],[-2.4669269,54.5566971],[-2.4662375,54.5562819],[-2.4637780,54.5574391],[-2.4628580,54.5568169],[-2.4607612,54.5560985],[-2.4608248,54.5560719],[-2.4611789,54.5558914],[-2.4613774,54.5558168],[-2.4615973,54.5557577],[-2.4617475,54.5557297],[-2.4618816,54.5556519],[-2.4620104,54.5556115],[-2.4624771,54.5555275],[-2.4627131,54.5555150],[-2.4628741,54.5554839],[-2.4630082,54.5554404],[-2.4632335,54.5553346],[-2.4633944,54.5552164],[-2.4634749,54.5551106],[-2.4635178,54.5550235],[-2.4635285,54.5548213],[-2.4635768,54.5546346],[-2.4635875,54.5544884],[-2.4636090,54.5544075],[-2.4636465,54.5543515],[-2.4636573,54.5542769],[-2.4636358,54.5541804],[-2.4637377,54.5540155],[-2.4639094,54.5538724],[-2.4643493,54.5535831],[-2.4645370,54.5535084],[-2.4647141,54.5534804],[-2.4648052,54.5534836],[-2.4648213,54.5535116],[-2.4648750,54.5535396],[-2.4650842,54.5535893],[-2.4652451,54.5536516],[-2.4652719,54.5536796],[-2.4653900,54.5537355],[-2.4655455,54.5537853],[-2.4658459,54.5539502],[-2.4663556,54.5542738],[-2.4668008,54.5545164],[-2.4668330,54.5545506],[-2.4668437,54.5546782],[-2.4668598,54.5547031],[-2.4670798,54.5548306],[-2.4671817,54.5549053],[-2.4674177,54.5549364],[-2.4677664,54.5550484],[-2.4681956,54.5551448],[-2.4684101,54.5551759],[-2.4691129,54.5552195],[-2.4691585,54.5552164]]] }
134
+ }, {
135
+ type: 'Feature',
136
+ id: 2,
137
+ properties: { name: 'Feature 2', land_use: 'Arable' },
138
+ geometry: { type: 'Polygon', coordinates: [[[-2.4611682,54.5562375],[-2.4628580,54.5568161],[-2.4636841,54.5573753],[-2.4637793,54.5574398],[-2.4641401,54.5576751],[-2.4642567,54.5577999],[-2.4641307,54.5578823],[-2.4636841,54.5582502],[-2.4624221,54.5592884],[-2.4623376,54.5592534],[-2.4615370,54.5586429],[-2.4611869,54.5582852],[-2.4605258,54.5581071],[-2.4598472,54.5578186],[-2.4611682,54.5562375]]] }
139
+ }, {
140
+ type: 'Feature',
141
+ id: 3,
142
+ properties: { name: 'Feature 3', land_use: 'Arable' },
143
+ geometry: { type: 'Polygon', coordinates: [[[-2.4598472,54.5578186],[-2.4605258,54.5581067],[-2.4611869,54.5582852],[-2.4615376,54.5586433],[-2.4623108,54.5592332],[-2.4623376,54.5592534],[-2.4624221,54.5592884],[-2.4623108,54.5594120],[-2.4616731,54.5601189],[-2.4586053,54.5601189],[-2.4584410,54.5600299],[-2.4580038,54.5596574],[-2.4581815,54.5593953],[-2.4585778,54.5590702],[-2.4587287,54.5589353],[-2.4589198,54.5586736],[-2.4591116,54.5582136],[-2.4598472,54.5578186]]] }
144
+ }, {
145
+ type: 'Feature',
146
+ id: 4,
147
+ properties: { name: 'Feature 4', land_use: 'Permanent grassland' },
148
+ geometry: { type: 'Polygon', coordinates: [[[-2.4633756,54.5612877],[-2.4613908,54.5604315],[-2.4624221,54.5592884],[-2.4641307,54.5578823],[-2.4642567,54.5577999],[-2.4653631,54.5591733],[-2.4659613,54.5597013],[-2.4633756,54.5612877]]] }
149
+ }, {
150
+ type: 'Feature',
151
+ id: 5,
152
+ properties: { name: 'Feature 5', land_use: 'Arable' },
153
+ geometry: { type: 'Polygon', coordinates: [[[-2.4678040,54.5590679],[-2.4661879,54.5595952],[-2.4659613,54.5597013],[-2.4653638,54.5591737],[-2.4642567,54.5577999],[-2.4641401,54.5576751],[-2.4637793,54.5574398],[-2.4662369,54.5562822],[-2.4669282,54.5566975],[-2.4678040,54.5563320],[-2.4678040,54.5590679]]] }
154
+ }, {
155
+ type: 'Feature',
156
+ id: 6,
157
+ properties: { name: 'Feature 6', land_use: 'Permanent grassland' },
158
+ geometry: { type: 'Polygon', coordinates: [[[-2.4669316,54.5603767],[-2.4676430,54.5613102],[-2.4673292,54.5614556],[-2.4671616,54.5617468],[-2.4658446,54.5625528],[-2.4651546,54.5621528],[-2.4639215,54.5633040],[-2.4633146,54.5633040],[-2.4628372,54.5630921],[-2.4631195,54.5628195],[-2.4643741,54.5618374],[-2.4665071,54.5604793],[-2.4667056,54.5604187],[-2.4669316,54.5603767]]] }
159
+ }, {
160
+ type: 'Feature',
161
+ id: 7,
162
+ properties: { name: 'Feature 7', land_use: 'Woodland' },
163
+ geometry: { type: 'Polygon', coordinates: [[[-2.4599129,54.5564203],[-2.4599773,54.5565478],[-2.4599773,54.5565852],[-2.4599344,54.5566256],[-2.4596876,54.5566069],[-2.4594945,54.5566132],[-2.4593657,54.5566505],[-2.4592584,54.5567158],[-2.4592048,54.5567780],[-2.4591780,54.5568496],[-2.4591887,54.5569616],[-2.4591297,54.5570829],[-2.4590009,54.5572726],[-2.4589419,54.5573162],[-2.4588561,54.5574686],[-2.4587435,54.5575588],[-2.4586684,54.5575837],[-2.4585879,54.5575962],[-2.4584001,54.5575837],[-2.4583304,54.5575899],[-2.4580836,54.5576397],[-2.4579817,54.5576895],[-2.4579227,54.5576988],[-2.4578154,54.5576988],[-2.4576384,54.5576739],[-2.4574614,54.5576739],[-2.4573044,54.5577050],[-2.4563093,54.5573092],[-2.4563871,54.5569849],[-2.4564891,54.5560664],[-2.4565601,54.5559039],[-2.4567747,54.5559412],[-2.4571985,54.5559817],[-2.4573219,54.5560097],[-2.4576116,54.5560936],[-2.4582446,54.5562181],[-2.4584913,54.5562959],[-2.4590331,54.5563705],[-2.4599129,54.5564203]]] }
164
+ }]
165
+ }
166
+
167
+ const datasetsPlugin = defra.datasetsPlugin({
168
+ datasets: [{
169
+ id: 'field-parcels',
170
+ label: 'Field parcels',
171
+ geojson: geojson,
172
+ minZoom: 10,
173
+ maxZoom: 24,
174
+ showInKey: true,
175
+ showInMenu: true,
176
+ sublayers: [{
177
+ id: 'arable',
178
+ label: 'Arable',
179
+ filter: ['==', ['get', 'land_use'], 'Arable'],
180
+ style: {
181
+ stroke: '#6D4C41',
182
+ fillPattern: 'horizontal-hatch',
183
+ fillPatternForegroundColor: '#6D4C41',
184
+ fillPatternBackgroundColor: 'transparent'
185
+ }
186
+ }, {
187
+ id: 'permanent-grassland',
188
+ label: 'Permanent grassland',
189
+ filter: ['==', ['get', 'land_use'], 'Permanent grassland'],
190
+ style: {
191
+ stroke: '#00897B',
192
+ fillPattern: 'diagonal-cross-hatch',
193
+ fillPatternForegroundColor: '#00897B',
194
+ fillPatternBackgroundColor: 'transparent'
195
+ }
196
+ }, {
197
+ id: 'woodland',
198
+ label: 'Woodland',
199
+ filter: ['==', ['get', 'land_use'], 'Woodland'],
200
+ style: {
201
+ stroke: '#2E7D32',
202
+ fillPattern: 'dot',
203
+ fillPatternForegroundColor: '#2E7D32',
204
+ fillPatternBackgroundColor: 'transparent'
205
+ }
206
+ }]
207
+ }]
208
+ })
209
+
210
+ new defra.InteractiveMap('my-map', {
211
+ behaviour: 'inline',
212
+ mapProvider: defra.maplibreProvider(),
213
+ mapStyle: {
214
+ url: 'https://your-tile-url/style.json',
215
+ attribution: 'Your tile attribution'
216
+ },
217
+ center: [-2.464, 54.558],
218
+ zoom: 14,
219
+ containerHeight: '516px',
220
+ plugins: [datasetsPlugin]
221
+ })
222
+ </script>
223
+ `
224
+ }
225
+ ]} />
@@ -0,0 +1,177 @@
1
+ import DemoMapSymbols from '../../demo/DemoMapSymbols.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
3
+
4
+ # Add symbols
5
+
6
+ Use the datasets plugin to overlay GeoJSON data on your map. Each dataset can contain sublayers with independent filters and styles. This example shows historic monument points categorised by period, each styled with a distinct symbol and colour.
7
+
8
+ <DemoMapSymbols />
9
+
10
+ <CodeTabs tabs={[
11
+ {
12
+ label: 'ESM',
13
+ language: 'js',
14
+ code: `
15
+ import InteractiveMap from '@defra/interactive-map'
16
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
17
+ import createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'
18
+
19
+ const symbolGraphic = 'M3 15H1V1h2v2h2V1h2v5h2V4h2v2h2V4h2v11H6V9H3v6z'
20
+
21
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
22
+ const geojson = {
23
+ type: 'FeatureCollection',
24
+ features: [{
25
+ type: 'Feature',
26
+ properties: { category: 'prehistoric', name: 'Prehistoric feature' },
27
+ geometry: { type: 'Point', coordinates: [-2.4615, 54.5616] }
28
+ }, {
29
+ type: 'Feature',
30
+ properties: { category: 'roman', name: 'Roman feature' },
31
+ geometry: { type: 'Point', coordinates: [-2.4628, 54.5541] }
32
+ }, {
33
+ type: 'Feature',
34
+ properties: { category: 'medieval', name: 'Medieval feature' },
35
+ geometry: { type: 'Point', coordinates: [-2.4578, 54.5569] }
36
+ }]
37
+ }
38
+
39
+ const datasetsPlugin = createDatasetsPlugin({
40
+ datasets: [{
41
+ id: 'historic-monuments',
42
+ label: 'Historic monuments',
43
+ geojson: geojson,
44
+ minZoom: 10,
45
+ maxZoom: 24,
46
+ showInKey: true,
47
+ showInMenu: true,
48
+ sublayers: [{
49
+ id: 'prehistoric',
50
+ label: 'Prehistoric',
51
+ filter: ['in', ['get', 'category'], 'prehistoric'],
52
+ style: {
53
+ symbol: 'square',
54
+ symbolGraphic,
55
+ symbolBackgroundColor: '#00897B'
56
+ }
57
+ }, {
58
+ id: 'roman',
59
+ label: 'Roman',
60
+ filter: ['in', ['get', 'category'], 'roman'],
61
+ style: {
62
+ symbol: 'square',
63
+ symbolGraphic,
64
+ symbolBackgroundColor: '#ca3535'
65
+ }
66
+ }, {
67
+ id: 'medieval',
68
+ label: 'Medieval',
69
+ filter: ['in', ['get', 'category'], 'medieval'],
70
+ style: {
71
+ symbol: 'square',
72
+ symbolGraphic,
73
+ symbolBackgroundColor: '#1565C0'
74
+ }
75
+ }]
76
+ }]
77
+ })
78
+
79
+ new InteractiveMap('my-map', {
80
+ behaviour: 'inline',
81
+ mapProvider: maplibreProvider(),
82
+ mapStyle: {
83
+ url: 'https://your-tile-url/style.json',
84
+ attribution: 'Your tile attribution'
85
+ },
86
+ center: [-2.4608, 54.5574],
87
+ zoom: 14,
88
+ containerHeight: '516px',
89
+ plugins: [datasetsPlugin]
90
+ })
91
+ `
92
+ },
93
+ {
94
+ label: 'UMD',
95
+ language: 'html',
96
+ code: `
97
+ <script src="/your-assets-path/interactive-map/index.js"></script>
98
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
99
+ <script src="/your-assets-path/datasets-plugin/index.js"></script>
100
+
101
+ <script>
102
+ const symbolGraphic = 'M3 15H1V1h2v2h2V1h2v5h2V4h2v2h2V4h2v11H6V9H3v6z'
103
+
104
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
105
+ const geojson = {
106
+ type: 'FeatureCollection',
107
+ features: [{
108
+ type: 'Feature',
109
+ properties: { category: 'prehistoric', name: 'Prehistoric feature' },
110
+ geometry: { type: 'Point', coordinates: [-2.4615, 54.5616] }
111
+ }, {
112
+ type: 'Feature',
113
+ properties: { category: 'roman', name: 'Roman feature' },
114
+ geometry: { type: 'Point', coordinates: [-2.4628, 54.5541] }
115
+ }, {
116
+ type: 'Feature',
117
+ properties: { category: 'medieval', name: 'Medieval feature' },
118
+ geometry: { type: 'Point', coordinates: [-2.4578, 54.5569] }
119
+ }]
120
+ }
121
+
122
+ const datasetsPlugin = defra.datasetsPlugin({
123
+ datasets: [{
124
+ id: 'historic-monuments',
125
+ label: 'Historic monuments',
126
+ geojson: geojson,
127
+ minZoom: 10,
128
+ maxZoom: 24,
129
+ showInKey: true,
130
+ showInMenu: true,
131
+ sublayers: [{
132
+ id: 'prehistoric',
133
+ label: 'Prehistoric',
134
+ filter: ['in', ['get', 'category'], 'prehistoric'],
135
+ style: {
136
+ symbol: 'square',
137
+ symbolGraphic,
138
+ symbolBackgroundColor: '#00897B'
139
+ }
140
+ }, {
141
+ id: 'roman',
142
+ label: 'Roman',
143
+ filter: ['in', ['get', 'category'], 'roman'],
144
+ style: {
145
+ symbol: 'square',
146
+ symbolGraphic,
147
+ symbolBackgroundColor: '#ca3535'
148
+ }
149
+ }, {
150
+ id: 'medieval',
151
+ label: 'Medieval',
152
+ filter: ['in', ['get', 'category'], 'medieval'],
153
+ style: {
154
+ symbol: 'square',
155
+ symbolGraphic,
156
+ symbolBackgroundColor: '#1565C0'
157
+ }
158
+ }]
159
+ }]
160
+ })
161
+
162
+ new defra.InteractiveMap('my-map', {
163
+ behaviour: 'inline',
164
+ mapProvider: defra.maplibreProvider(),
165
+ mapStyle: {
166
+ url: 'https://your-tile-url/style.json',
167
+ attribution: 'Your tile attribution'
168
+ },
169
+ center: [-2.4608, 54.5574],
170
+ zoom: 14,
171
+ containerHeight: '516px',
172
+ plugins: [datasetsPlugin]
173
+ })
174
+ </script>
175
+ `
176
+ }
177
+ ]} />
@@ -24,7 +24,7 @@ Embed an interactive map directly on the page, allowing users to explore and int
24
24
  },
25
25
  center: [-1.6, 53.1],
26
26
  zoom: 6,
27
- containerHeight: '500px'
27
+ containerHeight: '516px'
28
28
  })
29
29
  `
30
30
  },
@@ -45,7 +45,7 @@ Embed an interactive map directly on the page, allowing users to explore and int
45
45
  },
46
46
  center: [-1.6, 53.1],
47
47
  zoom: 6,
48
- containerHeight: '500px'
48
+ containerHeight: '516px'
49
49
  })
50
50
  </script>
51
51
  `