From 15acc706a0ccd64c8bee2c45a4cc1a22e686368c Mon Sep 17 00:00:00 2001 From: Tawera Manaena Date: Tue, 29 Oct 2024 17:15:45 +1300 Subject: [PATCH 1/2] feat(landing): update logic to show labels by default for aerial layer --- .../landing/src/__tests__/map.config.test.ts | 46 +++++++++++++++++++ packages/landing/src/config.map.ts | 8 +++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/packages/landing/src/__tests__/map.config.test.ts b/packages/landing/src/__tests__/map.config.test.ts index a4de5f406..cf91ec0d7 100644 --- a/packages/landing/src/__tests__/map.config.test.ts +++ b/packages/landing/src/__tests__/map.config.test.ts @@ -174,4 +174,50 @@ describe('WindowUrl', () => { mc.updateFromUrl('i=01EDA2YFXH2JN264VG1HKBT625'); assert.equal(mc.layerId, '01EDA2YFXH2JN264VG1HKBT625'); }); + + it('should enable labels by default', () => { + // aerial layer & debug disabled + mc.updateFromUrl(''); + assert.equal(mc.layerId, 'aerial'); + assert.equal(mc.isDebug, false); + assert.equal(mc.labels, true); + + // aerial layer, labels enabled & debug disabled + mc.updateFromUrl('?labels=true'); + assert.equal(mc.layerId, 'aerial'); + assert.equal(mc.isDebug, false); + assert.equal(mc.labels, true); + }); + + it('should not enable labels by default', () => { + // aerial layer, but labels disabled + mc.updateFromUrl('?labels=false'); + assert.equal(mc.layerId, 'aerial'); + assert.equal(mc.isDebug, false); + assert.equal(mc.labels, false); + + // aerial layer, but debug enabled + mc.updateFromUrl('?debug'); + assert.equal(mc.layerId, 'aerial'); + assert.equal(mc.isDebug, true); + assert.equal(mc.labels, false); + + // aerial layer, labels disabled & debug enabled + mc.updateFromUrl('?labels=false&debug'); + assert.equal(mc.layerId, 'aerial'); + assert.equal(mc.isDebug, true); + assert.equal(mc.labels, false); + + // debug disabled, but individual layer + mc.updateFromUrl('i=abc123'); + assert.equal(mc.layerId, 'abc123'); + assert.equal(mc.isDebug, false); + assert.equal(mc.labels, false); + + // individual layer & debug enabled + mc.updateFromUrl('i=abc123&debug'); + assert.equal(mc.layerId, 'abc123'); + assert.equal(mc.isDebug, true); + assert.equal(mc.labels, false); + }); }); diff --git a/packages/landing/src/config.map.ts b/packages/landing/src/config.map.ts index 09c528a85..5f925833b 100644 --- a/packages/landing/src/config.map.ts +++ b/packages/landing/src/config.map.ts @@ -128,7 +128,7 @@ export class MapConfig extends Emitter { const config = urlParams.get('c') ?? urlParams.get('config'); const layerId = urlParams.get('i') ?? style ?? 'aerial'; const terrain = urlParams.get('t') ?? urlParams.get('terrain'); - const labels = Boolean(urlParams.get('labels')); + const labels = urlParams.get('labels'); const projectionParam = (urlParams.get('p') ?? urlParams.get('tileMatrix') ?? GoogleTms.identifier).toLowerCase(); let tileMatrix = TileMatrixSets.All.find((f) => f.identifier.toLowerCase() === projectionParam); @@ -145,7 +145,11 @@ export class MapConfig extends Emitter { this.style = style ?? null; this.layerId = layerId.startsWith('im_') ? layerId.slice(3) : layerId; this.tileMatrix = tileMatrix; - this.labels = labels; + if (labels == null) { + this.labels = layerId === 'aerial' && !this.debug.debug; + } else { + this.labels = labels === 'true'; + } if (this.layerId === 'topographic' && this.style == null) this.style = 'topographic'; this.emit('tileMatrix', this.tileMatrix); From 09904b97c46d50087edd2349f40d32ad70b15f2d Mon Sep 17 00:00:00 2001 From: Tawera Manaena Date: Thu, 31 Oct 2024 13:44:27 +1300 Subject: [PATCH 2/2] refactor(landing): revise logic for showing labels by default --- packages/landing/src/config.map.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/landing/src/config.map.ts b/packages/landing/src/config.map.ts index 5f925833b..2d0a899fe 100644 --- a/packages/landing/src/config.map.ts +++ b/packages/landing/src/config.map.ts @@ -69,7 +69,7 @@ export class MapConfig extends Emitter { } get isDebug(): boolean { - return this.debug.debug; + return this.debug.debug === true; } /** Map location in WGS84 */ @@ -146,9 +146,9 @@ export class MapConfig extends Emitter { this.layerId = layerId.startsWith('im_') ? layerId.slice(3) : layerId; this.tileMatrix = tileMatrix; if (labels == null) { - this.labels = layerId === 'aerial' && !this.debug.debug; + this.labels = layerId === 'aerial' && this.isDebug === false; } else { - this.labels = labels === 'true'; + this.labels = labels !== 'false'; } if (this.layerId === 'topographic' && this.style == null) this.style = 'topographic';