@defra/interactive-map 0.0.54-alpha → 0.0.55-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 (139) hide show
  1. package/assets/templates/add-polygons.njk +1 -1
  2. package/assets/templates/add-symbols.njk +4 -4
  3. package/assets/templates/draw-tools.njk +7 -7
  4. package/assets/templates/marker-panel.njk +5 -5
  5. package/assets/templates/place-marker.njk +8 -8
  6. package/assets/templates/search-control.njk +1 -1
  7. package/assets/templates/select-feature.njk +7 -7
  8. package/assets/templates/style-switcher.njk +4 -4
  9. package/assets/templates/toggle-marker-label.njk +3 -3
  10. package/dist/esm/im-core.js +1 -1
  11. package/dist/esm/im-shell.js +1 -1
  12. package/dist/esm/index.js +1 -1
  13. package/dist/umd/im-core.js +1 -1
  14. package/dist/umd/im-core.js.LICENSE.txt +0 -30
  15. package/dist/umd/index.js +1 -1
  16. package/dist/umd/index.js.LICENSE.txt +0 -20
  17. package/docs/api.md +3 -13
  18. package/docs/building-a-plugin.md +2 -2
  19. package/docs/examples/add-marker-with-panel.mdx +46 -44
  20. package/docs/examples/add-polygons.mdx +100 -98
  21. package/docs/examples/add-symbols.mdx +75 -73
  22. package/docs/examples/basic-map.mdx +16 -14
  23. package/docs/examples/button-map.mdx +16 -14
  24. package/docs/examples/draw-tools.mdx +119 -117
  25. package/docs/examples/place-marker.mdx +51 -49
  26. package/docs/examples/search-control.mdx +22 -20
  27. package/docs/examples/select-feature.mdx +107 -105
  28. package/docs/examples/style-switcher.mdx +47 -45
  29. package/docs/examples/toggle-marker-label.mdx +30 -28
  30. package/docs/getting-started.md +26 -24
  31. package/docs/plugins/draw.md +10 -10
  32. package/docs/plugins/interact.md +9 -9
  33. package/docs/plugins/plugin-descriptor.md +1 -1
  34. package/docs/plugins/search.md +3 -3
  35. package/docusaurus.config.cjs +23 -0
  36. package/package.json +3 -7
  37. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  38. package/plugins/beta/draw-es/dist/esm/index.js +1 -1
  39. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  40. package/plugins/beta/draw-ml/dist/esm/index.js +1 -1
  41. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  42. package/plugins/beta/draw-ml/dist/umd/index.js +1 -1
  43. package/plugins/beta/draw-ol/dist/esm/DrawMode.js +1 -1
  44. package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
  45. package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +1 -1
  46. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
  47. package/plugins/beta/draw-ol/dist/esm/index.js +1 -1
  48. package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
  49. package/plugins/beta/frame/dist/esm/index.js +1 -1
  50. package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
  51. package/plugins/beta/frame/dist/umd/index.js +1 -1
  52. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  53. package/plugins/beta/map-styles/dist/esm/index.js +1 -1
  54. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  55. package/plugins/beta/map-styles/dist/umd/index.js +1 -1
  56. package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
  57. package/plugins/beta/scale-bar/dist/esm/index.js +1 -1
  58. package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
  59. package/plugins/beta/scale-bar/dist/umd/index.js +1 -1
  60. package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
  61. package/plugins/beta/use-location/dist/esm/index.js +1 -1
  62. package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
  63. package/plugins/beta/use-location/dist/umd/index.js +1 -1
  64. package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
  65. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  66. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  67. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  68. package/plugins/datasets/dist/esm/index.js +1 -1
  69. package/plugins/datasets/dist/esm/layerAdapter.js +1 -1
  70. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  71. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  72. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  73. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  74. package/plugins/datasets/dist/umd/index.js +1 -1
  75. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  76. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  77. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  78. package/plugins/draw/dist/esm/index.js +1 -1
  79. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  80. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  81. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  82. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  83. package/plugins/draw/dist/umd/index.js +1 -1
  84. package/plugins/draw/src/adapters/maplibre/styles.js +3 -2
  85. package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
  86. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  87. package/plugins/interact/dist/esm/index.js +1 -1
  88. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  89. package/plugins/interact/dist/umd/index.js +1 -1
  90. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  91. package/plugins/map-key/dist/esm/index.js +1 -1
  92. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  93. package/plugins/map-key/dist/umd/index.js +1 -1
  94. package/plugins/menu/dist/esm/im-menu-plugin.js +1 -1
  95. package/plugins/menu/dist/esm/index.js +1 -1
  96. package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
  97. package/plugins/menu/dist/umd/index.js +1 -1
  98. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  99. package/plugins/search/dist/esm/index.js +1 -1
  100. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  101. package/plugins/search/dist/umd/index.js +1 -1
  102. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
  103. package/providers/beta/esri/dist/esm/index.js +1 -1
  104. package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +1 -1
  105. package/providers/beta/open-names/dist/esm/index.js +1 -1
  106. package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +1 -1
  107. package/providers/beta/open-names/dist/umd/index.js +1 -1
  108. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  109. package/providers/beta/openlayers/dist/esm/index.js +1 -1
  110. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  111. package/providers/beta/openlayers/dist/umd/index.js +1 -1
  112. package/providers/beta/openlayers/src/index.js +27 -4
  113. package/providers/beta/openlayers/src/index.test.js +47 -0
  114. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  115. package/providers/maplibre/dist/esm/index.js +1 -1
  116. package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
  117. package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
  118. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  119. package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
  120. package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
  121. package/providers/maplibre/dist/umd/index.js +1 -1
  122. package/providers/maplibre/src/index.js +41 -12
  123. package/providers/maplibre/src/index.test.js +43 -12
  124. package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
  125. package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
  126. package/providers/maplibre/src/utils/spatial.js +22 -12
  127. package/providers/maplibre/src/utils/spatial.test.js +6 -6
  128. package/providers/maplibre/src/utils/workerUrl.js +15 -0
  129. package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
  130. package/rollup.esm.mjs +38 -1
  131. package/src/InteractiveMap/InteractiveMap.js +2 -1
  132. package/src/InteractiveMap/InteractiveMap.test.js +9 -2
  133. package/src/InteractiveMap/domStateManager.js +21 -1
  134. package/src/InteractiveMap/domStateManager.test.js +48 -1
  135. package/src/InteractiveMap/polyfills.js +4 -3
  136. package/src/InteractiveMap/polyfills.test.js +12 -0
  137. package/src/types.js +3 -5
  138. package/webpack.dev.mjs +2 -0
  139. package/webpack.umd.mjs +28 -7
@@ -123,111 +123,113 @@ Use the datasets plugin to overlay GeoJSON polygon data on your map. This exampl
123
123
  label: 'UMD',
124
124
  language: 'html',
125
125
  code: `
126
- <script src="/your-assets-path/interactive-map/index.js"></script>
127
- <script src="/your-assets-path/maplibre-provider/index.js"></script>
128
- <script src="/your-assets-path/datasets-plugin/index.js"></script>
129
- <script src="/your-assets-path/map-key-plugin/index.js"></script>
126
+ <script defer src="/your-assets-path/interactive-map/index.js"></script>
127
+ <script defer src="/your-assets-path/maplibre-provider/index.js"></script>
128
+ <script defer src="/your-assets-path/datasets-plugin/index.js"></script>
129
+ <script defer src="/your-assets-path/map-key-plugin/index.js"></script>
130
130
 
131
131
  <script>
132
- // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
133
- const geojson = {
134
- type: 'FeatureCollection',
135
- features: [{
136
- type: 'Feature',
137
- id: 1,
138
- properties: { name: 'Large meadow', land_use: 'Permanent grassland' },
139
- 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]]] }
140
- }, {
141
- type: 'Feature',
142
- id: 2,
143
- properties: { name: 'Lamb field', land_use: 'Arable' },
144
- 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]]] }
145
- }, {
146
- type: 'Feature',
147
- id: 3,
148
- properties: { name: 'Small hay field', land_use: 'Arable' },
149
- 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]]] }
150
- }, {
151
- type: 'Feature',
152
- id: 4,
153
- properties: { name: 'The pasture', land_use: 'Permanent grassland' },
154
- 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]]] }
155
- }, {
156
- type: 'Feature',
157
- id: 5,
158
- properties: { name: 'Herdwick Croft', land_use: 'Arable' },
159
- 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]]] }
160
- }, {
161
- type: 'Feature',
162
- id: 6,
163
- properties: { name: "Wainwright's Rest", land_use: 'Permanent grassland' },
164
- 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]]] }
165
- }, {
166
- type: 'Feature',
167
- id: 7,
168
- properties: { name: 'Badger Sett Copse', land_use: 'Woodland' },
169
- 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]]] }
170
- }]
171
- }
172
-
173
- const datasetsPlugin = defra.datasetsPlugin({
174
- datasets: [{
175
- id: 'field-parcels',
176
- label: 'Field parcels',
177
- geojson: geojson,
178
- minZoom: 10,
179
- maxZoom: 24,
180
- showInKey: true,
181
- showInMenu: true,
182
- sublayers: [{
183
- id: 'arable',
184
- label: 'Arable',
185
- filter: ['==', ['get', 'land_use'], 'Arable'],
186
- style: {
187
- stroke: '#573C34',
188
- fillPattern: 'horizontal-hatch',
189
- fillPatternForegroundColor: '#573C34',
190
- fillPatternBackgroundColor: 'transparent'
191
- }
132
+ document.addEventListener('DOMContentLoaded', function () {
133
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
134
+ const geojson = {
135
+ type: 'FeatureCollection',
136
+ features: [{
137
+ type: 'Feature',
138
+ id: 1,
139
+ properties: { name: 'Large meadow', land_use: 'Permanent grassland' },
140
+ 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]]] }
192
141
  }, {
193
- id: 'permanent-grassland',
194
- label: 'Permanent grassland',
195
- filter: ['==', ['get', 'land_use'], 'Permanent grassland'],
196
- style: {
197
- stroke: '#005149',
198
- fillPattern: 'diagonal-cross-hatch',
199
- fillPatternForegroundColor: '#005149',
200
- fillPatternBackgroundColor: 'transparent'
201
- }
142
+ type: 'Feature',
143
+ id: 2,
144
+ properties: { name: 'Lamb field', land_use: 'Arable' },
145
+ 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]]] }
202
146
  }, {
203
- id: 'woodland',
204
- label: 'Woodland',
205
- filter: ['==', ['get', 'land_use'], 'Woodland'],
206
- style: {
207
- stroke: '#1E5020',
208
- fillPattern: 'dot',
209
- fillPatternForegroundColor: '#1E5020',
210
- fillPatternBackgroundColor: 'transparent'
211
- }
147
+ type: 'Feature',
148
+ id: 3,
149
+ properties: { name: 'Small hay field', land_use: 'Arable' },
150
+ 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]]] }
151
+ }, {
152
+ type: 'Feature',
153
+ id: 4,
154
+ properties: { name: 'The pasture', land_use: 'Permanent grassland' },
155
+ 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]]] }
156
+ }, {
157
+ type: 'Feature',
158
+ id: 5,
159
+ properties: { name: 'Herdwick Croft', land_use: 'Arable' },
160
+ 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]]] }
161
+ }, {
162
+ type: 'Feature',
163
+ id: 6,
164
+ properties: { name: "Wainwright's Rest", land_use: 'Permanent grassland' },
165
+ 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]]] }
166
+ }, {
167
+ type: 'Feature',
168
+ id: 7,
169
+ properties: { name: 'Badger Sett Copse', land_use: 'Woodland' },
170
+ 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]]] }
212
171
  }]
213
- }]
214
- })
172
+ }
173
+
174
+ const datasetsPlugin = defra.datasetsPlugin({
175
+ datasets: [{
176
+ id: 'field-parcels',
177
+ label: 'Field parcels',
178
+ geojson: geojson,
179
+ minZoom: 10,
180
+ maxZoom: 24,
181
+ showInKey: true,
182
+ showInMenu: true,
183
+ sublayers: [{
184
+ id: 'arable',
185
+ label: 'Arable',
186
+ filter: ['==', ['get', 'land_use'], 'Arable'],
187
+ style: {
188
+ stroke: '#573C34',
189
+ fillPattern: 'horizontal-hatch',
190
+ fillPatternForegroundColor: '#573C34',
191
+ fillPatternBackgroundColor: 'transparent'
192
+ }
193
+ }, {
194
+ id: 'permanent-grassland',
195
+ label: 'Permanent grassland',
196
+ filter: ['==', ['get', 'land_use'], 'Permanent grassland'],
197
+ style: {
198
+ stroke: '#005149',
199
+ fillPattern: 'diagonal-cross-hatch',
200
+ fillPatternForegroundColor: '#005149',
201
+ fillPatternBackgroundColor: 'transparent'
202
+ }
203
+ }, {
204
+ id: 'woodland',
205
+ label: 'Woodland',
206
+ filter: ['==', ['get', 'land_use'], 'Woodland'],
207
+ style: {
208
+ stroke: '#1E5020',
209
+ fillPattern: 'dot',
210
+ fillPatternForegroundColor: '#1E5020',
211
+ fillPatternBackgroundColor: 'transparent'
212
+ }
213
+ }]
214
+ }]
215
+ })
215
216
 
216
- const mapKeyPlugin = defra.mapKeyPlugin()
217
+ const mapKeyPlugin = defra.mapKeyPlugin()
217
218
 
218
- new defra.InteractiveMap('my-map', {
219
- behaviour: 'inline',
220
- mapProvider: defra.maplibreProvider(),
221
- mapStyle: {
222
- url: 'https://your-tile-url/style.json',
223
- logo: '/path/to/logo.svg',
224
- logoAltText: 'Your logo alt text',
225
- attribution: 'Your tile attribution'
226
- },
227
- center: [-2.464, 54.558],
228
- zoom: 14,
229
- containerHeight: '516px',
230
- plugins: [datasetsPlugin, mapKeyPlugin]
219
+ new defra.InteractiveMap('my-map', {
220
+ behaviour: 'inline',
221
+ mapProvider: defra.maplibreProvider(),
222
+ mapStyle: {
223
+ url: 'https://your-tile-url/style.json',
224
+ logo: '/path/to/logo.svg',
225
+ logoAltText: 'Your logo alt text',
226
+ attribution: 'Your tile attribution'
227
+ },
228
+ center: [-2.464, 54.558],
229
+ zoom: 14,
230
+ containerHeight: '516px',
231
+ plugins: [datasetsPlugin, mapKeyPlugin]
232
+ })
231
233
  })
232
234
  </script>
233
235
  `
@@ -99,87 +99,89 @@ Use the datasets plugin to overlay GeoJSON data on your map. Each dataset can co
99
99
  label: 'UMD',
100
100
  language: 'html',
101
101
  code: `
102
- <script src="/your-assets-path/interactive-map/index.js"></script>
103
- <script src="/your-assets-path/maplibre-provider/index.js"></script>
104
- <script src="/your-assets-path/datasets-plugin/index.js"></script>
105
- <script src="/your-assets-path/map-key-plugin/index.js"></script>
102
+ <script defer src="/your-assets-path/interactive-map/index.js"></script>
103
+ <script defer src="/your-assets-path/maplibre-provider/index.js"></script>
104
+ <script defer src="/your-assets-path/datasets-plugin/index.js"></script>
105
+ <script defer src="/your-assets-path/map-key-plugin/index.js"></script>
106
106
 
107
107
  <script>
108
- const symbolGraphic = 'M3 15H1V1h2v2h2V1h2v5h2V4h2v2h2V4h2v11H6V9H3v6z'
109
-
110
- // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
111
- const geojson = {
112
- type: 'FeatureCollection',
113
- features: [{
114
- type: 'Feature',
115
- properties: { category: 'prehistoric', name: 'Prehistoric feature' },
116
- geometry: { type: 'Point', coordinates: [-2.4615, 54.5616] }
117
- }, {
118
- type: 'Feature',
119
- properties: { category: 'roman', name: 'Roman feature' },
120
- geometry: { type: 'Point', coordinates: [-2.4628, 54.5541] }
121
- }, {
122
- type: 'Feature',
123
- properties: { category: 'medieval', name: 'Medieval feature' },
124
- geometry: { type: 'Point', coordinates: [-2.4578, 54.5569] }
125
- }]
126
- }
108
+ document.addEventListener('DOMContentLoaded', function () {
109
+ const symbolGraphic = 'M3 15H1V1h2v2h2V1h2v5h2V4h2v2h2V4h2v11H6V9H3v6z'
127
110
 
128
- const datasetsPlugin = defra.datasetsPlugin({
129
- datasets: [{
130
- id: 'historic-monuments',
131
- label: 'Historic monuments',
132
- geojson: geojson,
133
- minZoom: 10,
134
- maxZoom: 24,
135
- showInKey: true,
136
- showInMenu: true,
137
- sublayers: [{
138
- id: 'prehistoric',
139
- label: 'Prehistoric',
140
- filter: ['in', ['get', 'category'], 'prehistoric'],
141
- style: {
142
- symbol: 'square',
143
- symbolGraphic,
144
- symbolBackgroundColor: '#00897B'
145
- }
111
+ // GeoJSON can also be loaded from a URL; use the tiles property for vector tile sources
112
+ const geojson = {
113
+ type: 'FeatureCollection',
114
+ features: [{
115
+ type: 'Feature',
116
+ properties: { category: 'prehistoric', name: 'Prehistoric feature' },
117
+ geometry: { type: 'Point', coordinates: [-2.4615, 54.5616] }
146
118
  }, {
147
- id: 'roman',
148
- label: 'Roman',
149
- filter: ['in', ['get', 'category'], 'roman'],
150
- style: {
151
- symbol: 'square',
152
- symbolGraphic,
153
- symbolBackgroundColor: '#ca3535'
154
- }
119
+ type: 'Feature',
120
+ properties: { category: 'roman', name: 'Roman feature' },
121
+ geometry: { type: 'Point', coordinates: [-2.4628, 54.5541] }
155
122
  }, {
156
- id: 'medieval',
157
- label: 'Medieval',
158
- filter: ['in', ['get', 'category'], 'medieval'],
159
- style: {
160
- symbol: 'square',
161
- symbolGraphic,
162
- symbolBackgroundColor: '#1565C0'
163
- }
123
+ type: 'Feature',
124
+ properties: { category: 'medieval', name: 'Medieval feature' },
125
+ geometry: { type: 'Point', coordinates: [-2.4578, 54.5569] }
164
126
  }]
165
- }]
166
- })
127
+ }
167
128
 
168
- const mapKeyPlugin = defra.mapKeyPlugin()
129
+ const datasetsPlugin = defra.datasetsPlugin({
130
+ datasets: [{
131
+ id: 'historic-monuments',
132
+ label: 'Historic monuments',
133
+ geojson: geojson,
134
+ minZoom: 10,
135
+ maxZoom: 24,
136
+ showInKey: true,
137
+ showInMenu: true,
138
+ sublayers: [{
139
+ id: 'prehistoric',
140
+ label: 'Prehistoric',
141
+ filter: ['in', ['get', 'category'], 'prehistoric'],
142
+ style: {
143
+ symbol: 'square',
144
+ symbolGraphic: symbolGraphic,
145
+ symbolBackgroundColor: '#00897B'
146
+ }
147
+ }, {
148
+ id: 'roman',
149
+ label: 'Roman',
150
+ filter: ['in', ['get', 'category'], 'roman'],
151
+ style: {
152
+ symbol: 'square',
153
+ symbolGraphic: symbolGraphic,
154
+ symbolBackgroundColor: '#ca3535'
155
+ }
156
+ }, {
157
+ id: 'medieval',
158
+ label: 'Medieval',
159
+ filter: ['in', ['get', 'category'], 'medieval'],
160
+ style: {
161
+ symbol: 'square',
162
+ symbolGraphic: symbolGraphic,
163
+ symbolBackgroundColor: '#1565C0'
164
+ }
165
+ }]
166
+ }]
167
+ })
169
168
 
170
- new defra.InteractiveMap('my-map', {
171
- behaviour: 'inline',
172
- mapProvider: defra.maplibreProvider(),
173
- mapStyle: {
174
- url: 'https://your-tile-url/style.json',
175
- logo: '/path/to/logo.svg',
176
- logoAltText: 'Your logo alt text',
177
- attribution: 'Your tile attribution'
178
- },
179
- center: [-2.4608, 54.5574],
180
- zoom: 14,
181
- containerHeight: '516px',
182
- plugins: [datasetsPlugin, mapKeyPlugin]
169
+ const mapKeyPlugin = defra.mapKeyPlugin()
170
+
171
+ new defra.InteractiveMap('my-map', {
172
+ behaviour: 'inline',
173
+ mapProvider: defra.maplibreProvider(),
174
+ mapStyle: {
175
+ url: 'https://your-tile-url/style.json',
176
+ logo: '/path/to/logo.svg',
177
+ logoAltText: 'Your logo alt text',
178
+ attribution: 'Your tile attribution'
179
+ },
180
+ center: [-2.4608, 54.5574],
181
+ zoom: 14,
182
+ containerHeight: '516px',
183
+ plugins: [datasetsPlugin, mapKeyPlugin]
184
+ })
183
185
  })
184
186
  </script>
185
187
  `
@@ -34,22 +34,24 @@ Embed an interactive map directly on the page, allowing users to explore and int
34
34
  label: 'UMD',
35
35
  language: 'html',
36
36
  code: `
37
- <script src="/your-assets-path/interactive-map/index.js"></script>
38
- <script src="/your-assets-path/maplibre-provider/index.js"></script>
37
+ <script defer src="/your-assets-path/interactive-map/index.js"></script>
38
+ <script defer src="/your-assets-path/maplibre-provider/index.js"></script>
39
39
 
40
40
  <script>
41
- new defra.InteractiveMap('my-map', {
42
- behaviour: 'inline',
43
- mapProvider: defra.maplibreProvider(),
44
- mapStyle: {
45
- url: 'https://your-tile-url/style.json',
46
- logo: '/path/to/logo.svg',
47
- logoAltText: 'Your logo alt text',
48
- attribution: 'Your tile attribution'
49
- },
50
- center: [-1.6, 53.1],
51
- zoom: 6,
52
- containerHeight: '516px'
41
+ document.addEventListener('DOMContentLoaded', function () {
42
+ new defra.InteractiveMap('my-map', {
43
+ behaviour: 'inline',
44
+ mapProvider: defra.maplibreProvider(),
45
+ mapStyle: {
46
+ url: 'https://your-tile-url/style.json',
47
+ logo: '/path/to/logo.svg',
48
+ logoAltText: 'Your logo alt text',
49
+ attribution: 'Your tile attribution'
50
+ },
51
+ center: [-1.6, 53.1],
52
+ zoom: 6,
53
+ containerHeight: '516px'
54
+ })
53
55
  })
54
56
  </script>
55
57
  `
@@ -34,22 +34,24 @@ Trigger the map to show on button press, allowing users to access the map when n
34
34
  label: 'UMD',
35
35
  language: 'html',
36
36
  code: `
37
- <script src="/your-assets-path/interactive-map/index.js"></script>
38
- <script src="/your-assets-path/maplibre-provider/index.js"></script>
37
+ <script defer src="/your-assets-path/interactive-map/index.js"></script>
38
+ <script defer src="/your-assets-path/maplibre-provider/index.js"></script>
39
39
 
40
40
  <script>
41
- new defra.InteractiveMap('my-map', {
42
- behaviour: 'buttonFirst',
43
- mapProvider: defra.maplibreProvider(),
44
- mapStyle: {
45
- url: 'https://your-tile-url/style.json',
46
- logo: '/path/to/logo.svg',
47
- logoAltText: 'Your logo alt text',
48
- attribution: 'Your tile attribution'
49
- },
50
- center: [-1.6, 53.1],
51
- zoom: 6,
52
- hasExitButton: true
41
+ document.addEventListener('DOMContentLoaded', function () {
42
+ new defra.InteractiveMap('my-map', {
43
+ behaviour: 'buttonFirst',
44
+ mapProvider: defra.maplibreProvider(),
45
+ mapStyle: {
46
+ url: 'https://your-tile-url/style.json',
47
+ logo: '/path/to/logo.svg',
48
+ logoAltText: 'Your logo alt text',
49
+ attribution: 'Your tile attribution'
50
+ },
51
+ center: [-1.6, 53.1],
52
+ zoom: 6,
53
+ hasExitButton: true
54
+ })
53
55
  })
54
56
  </script>
55
57
  `