Repository navigation
DF-1571: Fix issue with IM datasets when multiple maps on the same page #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e839253
cfab776
afd1951
f747ea4
98b5007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,10 +122,15 @@ export function getCentroidGridRef(feature) { | |
| } | ||
| } | ||
|
|
||
| /** @type {InteractiveMapInitConfig} */ | ||
| export const defaultConfig = { | ||
| zoom: '6', | ||
| center: [DEFAULT_LONG, DEFAULT_LAT] | ||
| /** | ||
| * Get the default config for a map | ||
| * @returns {InteractiveMapInitConfig} | ||
| */ | ||
| export const getDefaultConfig = () => { | ||
| return { | ||
| zoom: '6', | ||
| center: [DEFAULT_LONG, DEFAULT_LAT] | ||
| } | ||
| } | ||
|
|
||
| export const EVENTS = { | ||
|
|
@@ -166,6 +171,7 @@ export function initMaps(config = {}) { | |
| const { | ||
| assetPath = '/assets', | ||
| apiPath = '/form/api', | ||
| workerPath = '/assets/interactive-map/maplibre-gl-worker.mjs', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct? What if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case |
||
| data = defaultData | ||
| } = config | ||
| const locations = document.querySelectorAll('.app-location-field') | ||
|
|
@@ -197,11 +203,15 @@ export function initMaps(config = {}) { | |
| } | ||
|
|
||
| locations.forEach((location, index) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just my 2 cents:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| processLocation({ assetPath, apiPath, data }, location, index) | ||
| processLocation({ assetPath, apiPath, workerPath, data }, location, index) | ||
| }) | ||
|
|
||
| geospatials.forEach((geospatial, index) => { | ||
| processGeospatial({ assetPath, apiPath, data }, geospatial, index) | ||
| processGeospatial( | ||
| { assetPath, apiPath, workerPath, data }, | ||
| geospatial, | ||
| index | ||
| ) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -258,7 +268,7 @@ export function makeTileRequestTransformer(apiPath) { | |
| * @param {MapsEnvironmentConfig} mapsConfig - the map environment params | ||
| */ | ||
| export function createMap(mapId, initConfig, mapsConfig) { | ||
| const { assetPath, apiPath, data = defaultData } = mapsConfig | ||
| const { assetPath, apiPath, workerPath, data = defaultData } = mapsConfig | ||
| const logoAltText = 'Ordnance survey logo' | ||
| const interactPlugin = createInteractPlugin({ | ||
| markerColor: { outdoor: '#ff0000', dark: '#00ff00' }, | ||
|
|
@@ -270,7 +280,7 @@ export function createMap(mapId, initConfig, mapsConfig) { | |
| const map = new InteractiveMap(mapId, { | ||
| enableFullscreen: true, | ||
| autoColorScheme: false, | ||
| mapProvider: maplibreProvider(), | ||
| mapProvider: maplibreProvider({ workerUrl: workerPath }), | ||
| behaviour: 'inline', | ||
| minZoom: 6, | ||
| maxZoom: 18, | ||
|
|
@@ -448,6 +458,7 @@ export function getMapCountryLayers(apiPath, country) { | |
| * @typedef {object} MapsEnvironmentConfig | ||
| * @property {string} assetPath - the root asset path | ||
| * @property {string} apiPath - the root API path | ||
| * @property {string} workerPath - the maplibre worker path | ||
| * @property {TileData} data - the tile data config | ||
| */ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 theinteractive-mapspackage which is on version6.14.0There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved with 98b5007
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
maplibre-glas it is now bundled with IM