Skip to content

Commit

Permalink
FCRM-5476 Upgrade @defra-map to 0.4.0 (#452)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
markfee authored Jan 21, 2025
1 parent 182204f commit 56f7aed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
15 changes: 14 additions & 1 deletion client/js/defra-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 56f7aed

Please sign in to comment.