@defra/interactive-map 0.0.45-alpha → 0.0.46-fmp-1

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 (39) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/umd/im-core.js +1 -1
  4. package/docs/api/map-style-config.md +7 -0
  5. package/docs/assets/images/select-feature.jpg +0 -0
  6. package/govuk-prototype-kit.config.json +1 -0
  7. package/package.json +1 -1
  8. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  9. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  10. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  11. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  12. package/plugins/draw/src/adapters/openlayers/snap/snapEngine.js +10 -5
  13. package/plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js +1 -0
  14. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  15. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  16. package/providers/beta/openlayers/src/openlayersProvider.js +1 -1
  17. package/providers/beta/openlayers/src/openlayersProvider.test.js +22 -0
  18. package/providers/beta/openlayers/src/utils/highlightFeatures.js +23 -11
  19. package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +2 -0
  20. package/providers/beta/openlayers/src/utils/hoverCursor.js +6 -5
  21. package/providers/beta/openlayers/src/utils/hoverCursor.test.js +2 -1
  22. package/providers/beta/openlayers/src/utils/queryFeatures.js +9 -6
  23. package/providers/beta/openlayers/src/utils/queryFeatures.test.js +6 -3
  24. package/providers/beta/openlayers/src/utils/spatial.js +6 -15
  25. package/providers/beta/openlayers/src/utils/spatial.test.js +3 -9
  26. package/providers/beta/openlayers/src/utils/tileLayers.js +5 -0
  27. package/providers/beta/openlayers/src/utils/tileLayers.test.js +1 -1
  28. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  29. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  30. package/providers/maplibre/src/utils/labels.js +3 -3
  31. package/providers/maplibre/src/utils/labels.test.js +2 -2
  32. package/src/App/components/Attributions/Attributions.jsx +3 -1
  33. package/src/App/components/Attributions/Attributions.module.scss +7 -3
  34. package/src/App/components/Attributions/Attributions.test.jsx +8 -0
  35. package/src/App/hooks/useLayoutMeasurements.js +94 -29
  36. package/src/App/hooks/useLayoutMeasurements.test.js +55 -10
  37. package/src/App/layout/Layout.jsx +7 -3
  38. package/src/App/layout/layout.module.scss +30 -1
  39. package/src/types.js +5 -0
@@ -49,6 +49,11 @@ export class OLDrawManager {
49
49
  zIndex: 100
50
50
  })
51
51
  this._layer.set('layerId', 'draw')
52
+ // Tagged rather than left to `instanceof VectorLayer` on the reading side — a UMD
53
+ // consumer loads the provider and this plugin as independently-bundled scripts, each
54
+ // with its own copy of ol, so a class reference from one bundle never matches an
55
+ // instance from another.
56
+ this._layer.set('layerType', 'vector')
52
57
  map.addLayer(this._layer)
53
58
  }
54
59
 
@@ -1,6 +1,4 @@
1
1
  import { transform as projTransform } from 'ol/proj.js'
2
- import VectorLayer from 'ol/layer/Vector.js'
3
- import VectorTileLayer from 'ol/layer/VectorTile.js'
4
2
  import { testOLFeature, testRenderFeature, bestOf } from './snapGeometry.js'
5
3
 
6
4
  // VectorTile geometry is clipped to a rectangle (tile extent + buffer), producing fake
@@ -136,11 +134,15 @@ const pickVisibleCandidates = (best, candidates, context) => {
136
134
  return result
137
135
  }
138
136
 
139
- // Collected on each query — VectorTileLayers are replaced when the map style changes
137
+ // Collected on each query — VectorTileLayers are replaced when the map style changes.
138
+ // Classified by the `layerType` tag the provider sets at creation, not `instanceof
139
+ // VectorTileLayer` — this adapter and the provider are independently-bundled scripts in
140
+ // a UMD consumer, each with its own copy of ol, so a class reference from this bundle
141
+ // never matches an instance the provider built.
140
142
  const getVTLayers = (map) => {
141
143
  const layers = []
142
144
  map.getLayers().forEach(l => {
143
- if (l instanceof VectorTileLayer) { layers.push(l) }
145
+ if (l.get('layerType') === 'vectorTile') { layers.push(l) }
144
146
  })
145
147
  return layers
146
148
  }
@@ -155,7 +157,10 @@ export const createSnapEngine = (map, snapLayers = []) => {
155
157
  for (const entry of layers ?? []) {
156
158
  if (typeof entry === 'string') {
157
159
  vtLayerNames.add(entry)
158
- } else if (entry instanceof VectorLayer) {
160
+ } else if (typeof entry?.getSource === 'function') {
161
+ // Duck-typed rather than `instanceof VectorLayer` — an entry here can be a live
162
+ // layer object a consumer built themselves with their own copy of ol, which would
163
+ // never satisfy an instanceof check against this bundle's own copy of the class.
159
164
  olLayers.push(entry)
160
165
  } else {
161
166
  // unsupported layer type — skip
@@ -35,6 +35,7 @@ const renderFeature = (type, flat, ends = null, mapboxLayer = { id: 'boundaries'
35
35
  const setupVT = ({ features, withTileGrid = true, fillNeighbour = false }) => {
36
36
  const map = createEngineMap()
37
37
  const vtLayer = new VectorTileLayer({})
38
+ vtLayer.set('layerType', 'vectorTile') // mirrors the provider's own tagging in tileLayers.js
38
39
  if (withTileGrid) {
39
40
  jest.spyOn(vtLayer, 'getSource').mockReturnValue({ getTileGrid: () => tileGrid, getProjection: () => null })
40
41
  }