From 0ba1ca3e732fa4add0ec4d78adeedba92ccae2cb Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 10 Oct 2024 17:51:42 +0200 Subject: [PATCH 1/2] Fix wmts on page relaod --- src/client/cypress/e2e/settings/mapSettings.cy.js | 3 +++ src/client/src/components/map/mapComponent.jsx | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client/cypress/e2e/settings/mapSettings.cy.js b/src/client/cypress/e2e/settings/mapSettings.cy.js index 528c4ff19..60cb2e25f 100644 --- a/src/client/cypress/e2e/settings/mapSettings.cy.js +++ b/src/client/cypress/e2e/settings/mapSettings.cy.js @@ -33,6 +33,9 @@ describe("map settings", () => { cy.contains(wmsName); cy.contains(wmtsName); + // Reload page to verify layers are correctly added + cy.reload(true); + // Remove layers cy.get('[data-cy="settings-button"]').click(); cy.contains("Map").click(); diff --git a/src/client/src/components/map/mapComponent.jsx b/src/client/src/components/map/mapComponent.jsx index 0594df739..3aaa50f8c 100644 --- a/src/client/src/components/map/mapComponent.jsx +++ b/src/client/src/components/map/mapComponent.jsx @@ -18,6 +18,7 @@ import { Cluster } from "ol/source"; import TileWMS from "ol/source/TileWMS"; import VectorSource from "ol/source/Vector"; import WMTS from "ol/source/WMTS"; +import WMTSTileGrid from "ol/tilegrid/WMTS"; import proj4 from "proj4"; import PropTypes from "prop-types"; import { getGeojson } from "../../api-lib"; @@ -216,12 +217,22 @@ class MapComponent extends React.Component { ////// HANDLE CUSTOM USER LAYERS ////// addWMTSLayer(identifier, layer) { + const tileGridConfig = { + ...layer.conf.tileGrid, + origin: null, + origins: layer.conf.tileGrid.origins_, + resolutions: layer.conf.tileGrid.resolutions_ || [], + matrixIds: layer.conf.tileGrid.matrixIds_ || [], + }; + const wmtsLayer = new TileLayer({ visible: layer.visibility, - name: identifier, opacity: 1, source: new WMTS({ ...layer.conf, + extent: swissExtent, + tileGrid: new WMTSTileGrid(tileGridConfig), + projection: getProjection(this.srs), }), zIndex: layer.position + 1, }); From 370f0c14d4a0c36486796d6dde11119e07db3751 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 10 Oct 2024 18:03:21 +0200 Subject: [PATCH 2/2] Fix test --- src/client/cypress/e2e/settings/mapSettings.cy.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/cypress/e2e/settings/mapSettings.cy.js b/src/client/cypress/e2e/settings/mapSettings.cy.js index 60cb2e25f..a66741372 100644 --- a/src/client/cypress/e2e/settings/mapSettings.cy.js +++ b/src/client/cypress/e2e/settings/mapSettings.cy.js @@ -35,10 +35,12 @@ describe("map settings", () => { // Reload page to verify layers are correctly added cy.reload(true); + goToRouteAndAcceptTerms("/"); // Remove layers cy.get('[data-cy="settings-button"]').click(); cy.contains("Map").click(); + cy.wait(1000); cy.get('[data-cy="maps-for-user-box"]').contains(wmtsName); cy.get('[data-cy="maps-for-user-box"]').contains(wmsName); cy.get('[data-cy="delete-user-map-button"]').eq(0).click(); @@ -47,6 +49,7 @@ describe("map settings", () => { cy.wait("@setting"); //¯\_(ツ)_/¯ cy.get('[data-cy="maps-for-user-box"]').should("not.contain", wmsName); + cy.wait(1000); cy.get('[data-cy="delete-user-map-button"]').eq(0).click(); cy.get('[data-cy="maps-for-user-box"]').should("not.exist");