@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
@@ -135,7 +135,7 @@
135
135
  mapProvider: defra.maplibreProvider(),
136
136
  mapStyle: {
137
137
  url: 'https://labs.os.uk/tiles/styles/open-zoomstack-outdoor/style.json',
138
- attribution: `Contains OS data © Crown copyright and database rights ${new Date().getFullYear()}`,
138
+ attribution: 'Contains OS data © Crown copyright and database rights ' + new Date().getFullYear(),
139
139
  backgroundColor: '#f5f5f0'
140
140
  },
141
141
  center: [-2.464, 54.558],
@@ -79,7 +79,7 @@
79
79
  filter: ['in', ['get', 'category'], 'prehistoric'],
80
80
  style: {
81
81
  symbol: 'square',
82
- symbolGraphic,
82
+ symbolGraphic: symbolGraphic,
83
83
  symbolBackgroundColor: '#00897B'
84
84
  }
85
85
  }, {
@@ -88,7 +88,7 @@
88
88
  filter: ['in', ['get', 'category'], 'roman'],
89
89
  style: {
90
90
  symbol: 'square',
91
- symbolGraphic,
91
+ symbolGraphic: symbolGraphic,
92
92
  symbolBackgroundColor: '#ca3535'
93
93
  }
94
94
  }, {
@@ -97,7 +97,7 @@
97
97
  filter: ['in', ['get', 'category'], 'medieval'],
98
98
  style: {
99
99
  symbol: 'square',
100
- symbolGraphic,
100
+ symbolGraphic: symbolGraphic,
101
101
  symbolBackgroundColor: '#1565C0'
102
102
  }
103
103
  }]
@@ -111,7 +111,7 @@
111
111
  mapProvider: defra.maplibreProvider(),
112
112
  mapStyle: {
113
113
  url: 'https://labs.os.uk/tiles/styles/open-zoomstack-outdoor/style.json',
114
- attribution: `Contains OS data © Crown copyright and database rights ${new Date().getFullYear()}`,
114
+ attribution: 'Contains OS data © Crown copyright and database rights ' + new Date().getFullYear(),
115
115
  backgroundColor: '#f5f5f0'
116
116
  },
117
117
  center: [-2.4608, 54.5574],
@@ -146,13 +146,13 @@
146
146
  interactPlugin.enable()
147
147
  })
148
148
 
149
- interactiveMap.on('interact:selectionchange', function (e) {
150
- var singleFeature = e.selectedFeatures.length === 1
151
- var anyFeature = e.selectedFeatures.length > 0
152
- var isDrawFeature = singleFeature && DRAW_LAYERS.includes(e.selectedFeatures[0].layerId)
153
- var isPolygon = singleFeature && e.selectedFeatures[0].geometryType === 'Polygon'
154
- var allDrawFeatures = anyFeature && e.selectedFeatures.every(function (f) { return DRAW_LAYERS.includes(f.layerId) })
155
- selectedFeatureIds = e.selectedFeatures.map(function (f) { return f.featureId })
149
+ interactiveMap.on('interact:selectionchange', function (event) {
150
+ const singleFeature = event.selectedFeatures.length === 1
151
+ const anyFeature = event.selectedFeatures.length > 0
152
+ const isDrawFeature = singleFeature && DRAW_LAYERS.includes(event.selectedFeatures[0].layerId)
153
+ const isPolygon = singleFeature && event.selectedFeatures[0].geometryType === 'Polygon'
154
+ const allDrawFeatures = anyFeature && event.selectedFeatures.every(function (feature) { return DRAW_LAYERS.includes(feature.layerId) })
155
+ selectedFeatureIds = event.selectedFeatures.map(function (feature) { return feature.featureId })
156
156
  interactiveMap.toggleButtonState('drawPolygon', 'disabled', singleFeature)
157
157
  interactiveMap.toggleButtonState('drawLine', 'disabled', singleFeature)
158
158
  interactiveMap.toggleButtonState('editFeature', 'disabled', !isDrawFeature)
@@ -59,7 +59,7 @@
59
59
  plugins: [interactPlugin]
60
60
  })
61
61
 
62
- map.on('map:ready', () => {
62
+ map.on('map:ready', function () {
63
63
  map.addMarker('my-marker', [-2.968, 54.425])
64
64
  interactPlugin.enable()
65
65
  interactPlugin.selectMarker('my-marker')
@@ -74,16 +74,16 @@
74
74
  })
75
75
  })
76
76
 
77
- map.on('interact:selectionchange', ({ selectedMarkers }) => {
78
- if (selectedMarkers.length > 0) {
77
+ map.on('interact:selectionchange', function (event) {
78
+ if (event.selectedMarkers.length > 0) {
79
79
  map.showPanel('marker-info')
80
80
  } else {
81
81
  map.hidePanel('marker-info')
82
82
  }
83
83
  })
84
84
 
85
- map.on('app:panelclosed', ({ panelId }) => {
86
- if (panelId === 'marker-info') {
85
+ map.on('app:panelclosed', function (event) {
86
+ if (event.panelId === 'marker-info') {
87
87
  interactPlugin.unselectMarker('my-marker')
88
88
  }
89
89
  })
@@ -45,11 +45,11 @@
45
45
  <script src="/plugin-assets/%40defra%2Finteractive-map/plugins/interact/dist/umd/index.js"></script>
46
46
 
47
47
  <script>
48
- var interactPlugin = defra.interactPlugin({
48
+ const interactPlugin = defra.interactPlugin({
49
49
  interactionModes: ['placeMarker']
50
50
  })
51
51
 
52
- var map = new defra.InteractiveMap('map', {
52
+ const map = new defra.InteractiveMap('map', {
53
53
  behaviour: 'hybrid',
54
54
  mapProvider: defra.maplibreProvider(),
55
55
  mapStyle: {
@@ -65,7 +65,7 @@
65
65
  backLabel: 'Back',
66
66
  continueLabel: 'Continue',
67
67
  continueEnabledWhen: function (context) {
68
- return context.mapState.markers.items.some(function (m) { return m.id === 'location' })
68
+ return context.mapState.markers.items.some(function (item) { return item.id === 'location' })
69
69
  }
70
70
  }
71
71
  })
@@ -75,23 +75,23 @@
75
75
  })
76
76
 
77
77
  map.on('app:continue', function (context) {
78
- var marker = context.mapState.markers.items.find(function (m) { return m.id === 'location' })
78
+ const marker = context.mapState.markers.items.find(function (item) { return item.id === 'location' })
79
79
  // navigate to next step with marker.coords
80
80
  if (marker) {
81
81
  console.log('Continuing with marker at:', marker.coords)
82
82
  }
83
83
  })
84
84
 
85
- var continueBtn = document.getElementById('continue-btn')
86
- var externalButtons = document.getElementById('external-buttons')
85
+ const continueBtn = document.getElementById('continue-btn')
86
+ const externalButtons = document.getElementById('external-buttons')
87
87
 
88
88
  function setInline(isFullscreen) {
89
89
  externalButtons.hidden = isFullscreen
90
90
  }
91
91
 
92
- map.on('app:opened', function (e) { setInline(e.isFullscreen) })
92
+ map.on('app:opened', function (event) { setInline(event.isFullscreen) })
93
93
  map.on('app:closed', function () { externalButtons.hidden = true })
94
- map.on('app:fullscreenchange', function (e) { setInline(e.isFullscreen) })
94
+ map.on('app:fullscreenchange', function (event) { setInline(event.isFullscreen) })
95
95
 
96
96
  map.on('interact:markerchange', function () {
97
97
  continueBtn.disabled = false
@@ -72,7 +72,7 @@
72
72
  bounds: [bb[2], bb[0], bb[3], bb[1]]
73
73
  }
74
74
  })
75
- return Array.from(new Map(results.map(function (r) { return [r.text, r] })).values())
75
+ return Array.from(new Map(results.map(function (result) { return [result.text, result] })).values())
76
76
  }
77
77
  }
78
78
 
@@ -125,7 +125,7 @@
125
125
  plugins: [datasetsPlugin, interactPlugin]
126
126
  })
127
127
 
128
- map.on('map:ready', () => {
128
+ map.on('map:ready', function () {
129
129
  interactPlugin.enable()
130
130
 
131
131
  map.addPanel(PANEL_ID, {
@@ -138,19 +138,19 @@
138
138
  })
139
139
  })
140
140
 
141
- map.on('interact:selectionchange', ({ selectedFeatures }) => {
142
- if (selectedFeatures.length > 0) {
143
- const { name } = selectedFeatures[0].properties
141
+ map.on('interact:selectionchange', function (event) {
142
+ if (event.selectedFeatures.length > 0) {
143
+ const name = event.selectedFeatures[0].properties.name
144
144
  document.getElementById('parcel-info-content').innerHTML =
145
- `<p class="govuk-body govuk-!-margin-bottom-1">${name}</p>`
145
+ '<p class="govuk-body govuk-!-margin-bottom-1">' + name + '</p>'
146
146
  map.showPanel(PANEL_ID)
147
147
  } else {
148
148
  map.hidePanel(PANEL_ID)
149
149
  }
150
150
  })
151
151
 
152
- map.on('app:panelclosed', ({ panelId }) => {
153
- if (panelId === PANEL_ID) {
152
+ map.on('app:panelclosed', function (event) {
153
+ if (event.panelId === PANEL_ID) {
154
154
  interactPlugin.clear()
155
155
  }
156
156
  })
@@ -50,7 +50,7 @@
50
50
  label: 'Road',
51
51
  url: 'https://tiles.openfreemap.org/styles/liberty',
52
52
  thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/road-ofm-thumb.jpg',
53
- attribution,
53
+ attribution: attribution,
54
54
  backgroundColor: '#f5f5f0'
55
55
  },
56
56
  {
@@ -58,7 +58,7 @@
58
58
  label: 'Bright',
59
59
  url: 'https://tiles.openfreemap.org/styles/bright',
60
60
  thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/bright-ofm-thumb.jpg',
61
- attribution,
61
+ attribution: attribution,
62
62
  backgroundColor: '#f5f5f0'
63
63
  },
64
64
  {
@@ -66,13 +66,13 @@
66
66
  label: 'Dark',
67
67
  url: 'https://tiles.openfreemap.org/styles/fiord',
68
68
  thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/dark-ofm-thumb.jpg',
69
- attribution,
69
+ attribution: attribution,
70
70
  mapColorScheme: 'dark',
71
71
  appColorScheme: 'dark'
72
72
  }
73
73
  ]
74
74
 
75
- const mapStylesPlugin = defra.mapStylesPlugin({ mapStyles })
75
+ const mapStylesPlugin = defra.mapStylesPlugin({ mapStyles: mapStyles })
76
76
 
77
77
  new defra.InteractiveMap('map', {
78
78
  behaviour: 'inline',
@@ -59,7 +59,7 @@
59
59
  plugins: [interactPlugin]
60
60
  })
61
61
 
62
- map.on('map:ready', () => {
62
+ map.on('map:ready', function () {
63
63
  map.addMarker('my-marker', [-2.96, 54.43], {
64
64
  label: 'My location',
65
65
  showLabel: false
@@ -67,8 +67,8 @@
67
67
  interactPlugin.enable()
68
68
  })
69
69
 
70
- map.on('interact:selectionchange', ({ selectedMarkers }) => {
71
- map.updateMarker('my-marker', { showLabel: selectedMarkers.includes('my-marker') })
70
+ map.on('interact:selectionchange', function (event) {
71
+ map.updateMarker('my-marker', { showLabel: event.selectedMarkers.includes('my-marker') })
72
72
  })
73
73
  </script>
74
74
  {% endblock %}