From 56f7aed9779617d8eeee7864eba2a0cead9dc079 Mon Sep 17 00:00:00 2001 From: Mark Fee Date: Tue, 21 Jan 2025 17:45:19 +0000 Subject: [PATCH] FCRM-5476 Upgrade @defra-map to 0.4.0 (#452) * FCRM-5476 attempted an upgrade to 0.4.0 - getting invalid styles error * FCRM-5476 fixed issue causing map to fail if basemap had an incorrect value * FCRM-5476 refactor to avoid Sonar issue --- client/js/defra-map/index.js | 15 ++++++++++++++- package-lock.json | 28 ++++++++++++++-------------- package.json | 2 +- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/client/js/defra-map/index.js b/client/js/defra-map/index.js index bb06b3f0..b678868f 100644 --- a/client/js/defra-map/index.js +++ b/client/js/defra-map/index.js @@ -69,7 +69,20 @@ const surfaceWaterStyleLayers = [ // 'Risk of Flooding from Surface Water Depth CCSW1 > 900mm/1', // 'Risk of Flooding from Surface Water Depth CCSW1 > 1200mm/1' // ] + +const fixLocalStorage = () => { + // Temp fix until 0.5.0 + // Map will not load if localStorage basemap is not one of default OR dark + // but 0.3.0 sets the value to 'default,light', which screws up + // the map component after an upgrade to 0.4.0 + const basemap = window.localStorage.getItem('basemap') + if (basemap !== 'default' && basemap !== 'dark') { + window.localStorage.removeItem('basemap') + } +} + getDefraMapConfig().then((defraMapConfig) => { + fixLocalStorage() // Temp fix until 0.5.0 const getVectorTileUrl = (layerName) => `${defraMapConfig.agolVectorTileUrl}/${layerName + defraMapConfig.layerNameSuffix}/VectorTileServer` const getFeatureLayerUrl = (layerName) => `${defraMapConfig.agolServiceUrl}/${layerName}/FeatureServer` const getModelFeatureLayerUrl = (layerName) => `${defraMapConfig.agolServiceUrl}/${layerName + defraMapConfig.layerNameSuffix}/FeatureServer` @@ -364,7 +377,7 @@ getDefraMapConfig().then((defraMapConfig) => { maxZoom: 20, centre: [340367, 322766], height: '100%', - hasGeoLocation: true, + hasGeoLocation: false, framework: 'esri', symbols: [symbols.waterStorageAreas, symbols.floodDefences, symbols.mainRivers], requestCallback: getRequest, diff --git a/package-lock.json b/package-lock.json index d1610f99..7e53fbda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@babel/core": "^7.26.0", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.9", - "@defra/flood-map": "^0.3.0", + "@defra/flood-map": "^0.4.0", "@esri/arcgis-rest-feature-service": "^4.0.6", "@esri/arcgis-rest-request": "^4.2.3", "@hapi/boom": "^9.1.4", @@ -128,9 +128,9 @@ } }, "node_modules/@arcgis/core": { - "version": "4.31.3", - "resolved": "https://registry.npmjs.org/@arcgis/core/-/core-4.31.3.tgz", - "integrity": "sha512-exz54+7asVBITYnKRC0RpJl/r3YG12ZC+togFuVJlfCzk9DO60qCp6XxU/7Zw0QojV20bQFkKjBvzPY0udEtiA==", + "version": "4.31.6", + "resolved": "https://registry.npmjs.org/@arcgis/core/-/core-4.31.6.tgz", + "integrity": "sha512-+NSYtEJy/wRQcEX+f5OHBhg4MX26HeZFYghd7+VMTasalHUAD3y9PPiakLIfhahX/4EiSLuy25m1P93BBlybXg==", "dependencies": { "@esri/arcgis-html-sanitizer": "~4.1.0-next.4", "@esri/calcite-colors": "~6.1.0", @@ -1867,14 +1867,14 @@ "dev": true }, "node_modules/@defra/flood-map": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@defra/flood-map/-/flood-map-0.3.0.tgz", - "integrity": "sha512-qTMrz4LbXp7DcZsK46ETEdBZhZLuW7grZmOKh5Yfz2qaUqhLj8cZOhjBldyXaZjulSj5FEhWFkMeoSjMSeCY/Q==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@defra/flood-map/-/flood-map-0.4.0.tgz", + "integrity": "sha512-4Fx0zhpdA6CTEn5D3+e83Mg7n9yDmNffxR8u/JztpmeMezsGlyng4taXedQH3jL6iL/+CJ/b91cDgLj/DbCnsA==", "dependencies": { - "@arcgis/core": "^4.31.0", - "maplibre-gl": "^4.7.0", - "maplibre-gl-legacy": "npm:maplibre-gl@^1.15.0", - "preact": "^10.23.1" + "@arcgis/core": "^4.31.6", + "maplibre-gl": "^4.7.1", + "maplibre-gl-legacy": "npm:maplibre-gl@^1.15.3", + "preact": "^10.25.2" } }, "node_modules/@discoveryjs/json-ext": { @@ -16423,9 +16423,9 @@ "integrity": "sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw==" }, "node_modules/preact": { - "version": "10.24.3", - "resolved": "https://registry.npmjs.org/preact/-/preact-10.24.3.tgz", - "integrity": "sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==", + "version": "10.25.4", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.25.4.tgz", + "integrity": "sha512-jLdZDb+Q+odkHJ+MpW/9U5cODzqnB+fy2EiHSZES7ldV5LK7yjlVzTp7R8Xy6W6y75kfK8iWYtFVH7lvjwrCMA==", "funding": { "type": "opencollective", "url": "https://opencollective.com/preact" diff --git a/package.json b/package.json index bf6aee56..7950c7ea 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@babel/core": "^7.26.0", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.9", - "@defra/flood-map": "^0.3.0", + "@defra/flood-map": "^0.4.0", "@esri/arcgis-rest-feature-service": "^4.0.6", "@esri/arcgis-rest-request": "^4.2.3", "@hapi/boom": "^9.1.4",