1+ // @ts -expect-error - no types
2+ import InteractiveMap from '@defra/interactive-map'
3+ // @ts -expect-error - no types
4+ import createInteractPlugin from '@defra/interactive-map/plugins/interact'
5+ // @ts -expect-error - no types
6+ import createMapStylesPlugin from '@defra/interactive-map/plugins/map-styles'
7+ // @ts -expect-error - no types
8+ import createScaleBarPlugin from '@defra/interactive-map/plugins/scale-bar'
9+ // @ts -expect-error - no types
10+ import createSearchPlugin from '@defra/interactive-map/plugins/search'
11+ // @ts -expect-error - no types
12+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
113import { centroid } from '@turf/centroid'
214// @ts -expect-error - no types
315import OsGridRef , { LatLon } from 'geodesy/osgridref.js'
@@ -249,24 +261,17 @@ export function makeTileRequestTransformer(apiPath) {
249261export function createMap ( mapId , initConfig , mapsConfig ) {
250262 const { assetPath, apiPath, data = defaultData } = mapsConfig
251263 const logoAltText = 'Ordnance survey logo'
252-
253- // @ts -expect-error - Defra namespace currently comes from UMD support files
254- const defra = window . defra
255-
256- const interactPlugin = defra . interactPlugin ( {
264+ const interactPlugin = createInteractPlugin ( {
257265 markerColor : { outdoor : '#ff0000' , dark : '#00ff00' } ,
258266 interactionModes : [ 'placeMarker' ] ,
259267 multiSelect : false
260268 } )
261269
262270 /** @type {InteractiveMap } */
263- const map = new defra . InteractiveMap ( mapId , {
271+ const map = new InteractiveMap ( mapId , {
264272 enableFullscreen : true ,
265273 autoColorScheme : false ,
266- mapProvider : defra . maplibreProvider ( ) ,
267- reverseGeocodeProvider : defra . openNamesProvider ( {
268- url : `${ apiPath } /reverse-geocode-proxy?easting={easting}&northing={northing}`
269- } ) ,
274+ mapProvider : maplibreProvider ( ) ,
270275 behaviour : 'inline' ,
271276 minZoom : 6 ,
272277 maxZoom : 18 ,
@@ -275,7 +280,7 @@ export function createMap(mapId, initConfig, mapsConfig) {
275280 transformRequest : makeTileRequestTransformer ( apiPath ) ,
276281 ...initConfig ,
277282 plugins : [
278- defra . mapStylesPlugin ( {
283+ createMapStylesPlugin ( {
279284 mapStyles : [
280285 {
281286 id : 'outdoor' ,
@@ -319,12 +324,12 @@ export function createMap(mapId, initConfig, mapsConfig) {
319324 ]
320325 } ) ,
321326 interactPlugin ,
322- defra . searchPlugin ( {
327+ createSearchPlugin ( {
323328 osNamesURL : `${ apiPath } /geocode-proxy?query={query}` ,
324329 width : '300px' ,
325330 showMarker : false
326331 } ) ,
327- defra . scaleBarPlugin ( {
332+ createScaleBarPlugin ( {
328333 units : 'metric'
329334 } ) ,
330335 ...( initConfig . plugins ?? [ ] )
0 commit comments