diff --git a/packages/web/package.json b/packages/web/package.json index 49b9bbb43..8bfcda9ad 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -38,7 +38,8 @@ "@storybook/addon-a11y": "^8.0.9", "@storybook/addons": "^7.6.17", "@storybook/test": "^8.0.9", - "@storybook/theming": "^8.0.9" + "@storybook/theming": "^8.0.9", + "@maps4html/mapml": "^0.14.1" }, "devDependencies": { "@axe-core/puppeteer": "^4.7.3", @@ -47,7 +48,6 @@ "@babel/preset-typescript": "^7.21.0", "@cdssnc/gcds-tokens": "^1.20.2", "@fortawesome/fontawesome-free": "^6.3.0", - "@maps4html/mapml": "^0.14.1", "@stencil/angular-output-target": "file:../../utils/angular-output-target", "@stencil/postcss": "^2.1.0", "@stencil/sass": "^3.0.0-0", diff --git a/packages/web/src/components/gcds-map/gcds-map.tsx b/packages/web/src/components/gcds-map/gcds-map.tsx index 64f75ec2a..1496baef3 100644 --- a/packages/web/src/components/gcds-map/gcds-map.tsx +++ b/packages/web/src/components/gcds-map/gcds-map.tsx @@ -27,7 +27,7 @@ export class GcdsMap { // Reference the element this.mapViewer = this.el.shadowRoot.querySelector('mapml-viewer') as HTMLMapmlViewerElement; - // Handle readiness once the map is rendered + // Handle readiness once the map is rendered this.handleLayerReady(); } @@ -67,13 +67,13 @@ export class GcdsMap { } handleLayerReady() { - // Wait for the 'map-layer' custom element to be defined - customElements.whenDefined('map-layer').then(() => { - // Find all elements inside the mapml-viewer - const layers = Array.from(this.el.shadowRoot.querySelectorAll('map-layer')); + // Wait for the 'layer-' custom element to be defined + customElements.whenDefined('layer-').then(() => { + // Find all elements inside the mapml-viewer + const layers = Array.from(this.el.shadowRoot.querySelectorAll('layer-')); layers.forEach((layer) => { - // Now we know the element is fully defined, call whenReady() + // Now we know the element is fully defined, call whenReady() (layer as any).whenReady().then(() => { // Check for in the layer's shadow DOM and add 'checked' attribute // this is necessary only for geogratis MapML resources, but harmless @@ -106,13 +106,13 @@ export class GcdsMap { controlslist={this.controlslist ? this.controlslist : undefined} > {layers.map((layer) => ( - + > ))}