Skip to content

DF-1571: Fix issue with IM datasets when multiple maps on the same page - #485

Merged
davidjamesstone merged 5 commits into
mainfrom
fix/boundary-issue-with-multiple-maps-on-page
Oct 26, 2026
Merged

davidjamesstone merged 5 commits into
mainfrom
fix/boundary-issue-with-multiple-maps-on-page

Conversation

@davidjamesstone

Copy link
Copy Markdown
Contributor

Proposed change

When multiple maps are on the same page and datasets are configured (SSSI or country boundary) then the latter maps also get initialised with the same datasets as those above it when they shouldn't be.

This PR currently contains half the fix but we need to wait for an update to IM to make datasets not work globally (which Dan L is aware of and fixing)

Jira ticket: https://eaflood.atlassian.net/browse/DF-1571

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

- Updated @defra/interactive-map from 0.0.33-alpha to ^0.0.56-alpha in package.json.
- Changed import for createDrawPlugin from draw-ml to draw in geospatial-map.js and map.test.js.
- Added workerPath configuration for maplibre-gl worker in map.js.
- Updated map creation logic to include workerPath in createMap function.
- Added ignoreWarnings for maplibre-gl in webpack.config.js to suppress critical dependency warnings.
@davidjamesstone davidjamesstone changed the title Refactor map configuration to use getDefaultConfig function and update dataset plugin initialization Fix issue with IM datasets when multiple maps on the same page Oct 23, 2026
@davidjamesstone
davidjamesstone marked this pull request as ready for review October 23, 2026 16:09

@Scullyon Scullyon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, though I've left some comments including a package version to look into.

const {
assetPath = '/assets',
apiPath = '/form/api',
workerPath = '/assets/interactive-map/maplibre-gl-worker.mjs',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? What if assetPath is provided with the value files, but workerPath is undefined in config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case workerPath would default to /assets/interactive-map/maplibre-gl-worker.mjs

@@ -197,11 +203,15 @@ export function initMaps(config = {}) {
}

locations.forEach((location, index) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my 2 cents: locations seems a little ambiguous when talking about maps. Could be locations within the same map (eg points). Would locationQuestions or locationFields be a better name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locations here means LatLong, OSGR and EastingNorthing. These pre-date the geospatial question so probably would benefit from a rename - maybe one for tech debt.

Comment thread package.json
"@defra/interactive-map": "^0.0.56-alpha",
"@elastic/ecs-pino-format": "^1.5.0",
"@hapi/boom": "^10.0.1",
"@hapi/bourne": "^3.0.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below: "maplibre-gl": "^5.24.0" may need updating to v6+ to avoid conflict with the the interactive-maps package which is on version 6.14.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved with 98b5007

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed maplibre-gl as it is now bundled with IM

@sonarqubecloud

Copy link
Copy Markdown

@davidjamesstone davidjamesstone changed the title Fix issue with IM datasets when multiple maps on the same page DF-1571: Fix issue with IM datasets when multiple maps on the same page Oct 26, 2026
@davidjamesstone
davidjamesstone merged commit 44495b1 into main Oct 26, 2026
28 checks passed
@davidjamesstone
davidjamesstone deleted the fix/boundary-issue-with-multiple-maps-on-page branch October 26, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants