Skip to content

Commit af656bf

Browse files
feat(landing): enable labels upon first visit BM-1101 (#3364)
### Motivation As a Basemaps user, I would like to see labels when I arrive at the site so I can see the context of the imagery displayed to me. ### Modifications - Updated the **landing** package so that labels are enabled upon first visit to the site via the default Basemaps URL (https://basemaps.linz.govt.nz). Situations where labels are **not enabled** upon first visit: - The `labels` URL query string is `false`, e.g. https://basemaps.linz.govt.nz/?labels=false - The `debug` URL query string is present, e.g. https://basemaps.linz.govt.nz/?debug ### Verification - Added additional tests to the **landing** package's `map.config.test` test suite. #### Labels should be enabled | https://basemaps.linz.govt.nz | | - | | ![][default] | | Viewing the **aerial** layer and not in debug mode. Enable labels upon first visit. | #### Labels should be disabled | https://basemaps.linz.govt.nz/?labels=false | | - | | ![][labels=false] | | The `labels` query string is present and equals `false`. Don't enable labels upon first visit. | | https://basemaps.linz.govt.nz/?debug | | - | | ![][debug] | | In debug mode. Don't enable labels upon first visit. | | https://basemaps.linz.govt.nz/?i=ashburton-2023-0.1m | | - | | ![][individual_layer] | | _Adjusted viewport to show imagery_ | | Not viewing the `aerial` layer. Don't enable labels upon first visit. | --- Resolves bug: [BM-1114](https://toitutewhenua.atlassian.net/browse/BM-1114) [default]: https://github.com/user-attachments/assets/1b450c01-3409-400e-b794-6eccc6582021 [labels=false]: https://github.com/user-attachments/assets/2ca74653-d868-4420-8fd4-4e22273efa7d [debug]: https://github.com/user-attachments/assets/462ac80d-a603-47a7-9b9b-683b59988521 [individual_layer]: https://github.com/user-attachments/assets/bac0f8a7-9a67-4683-880b-5a5fe484ae8b [BM-1114]: https://toitutewhenua.atlassian.net/browse/BM-1114?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent dcc8a9b commit af656bf

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

packages/landing/src/__tests__/map.config.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,50 @@ describe('WindowUrl', () => {
174174
mc.updateFromUrl('i=01EDA2YFXH2JN264VG1HKBT625');
175175
assert.equal(mc.layerId, '01EDA2YFXH2JN264VG1HKBT625');
176176
});
177+
178+
it('should enable labels by default', () => {
179+
// aerial layer & debug disabled
180+
mc.updateFromUrl('');
181+
assert.equal(mc.layerId, 'aerial');
182+
assert.equal(mc.isDebug, false);
183+
assert.equal(mc.labels, true);
184+
185+
// aerial layer, labels enabled & debug disabled
186+
mc.updateFromUrl('?labels=true');
187+
assert.equal(mc.layerId, 'aerial');
188+
assert.equal(mc.isDebug, false);
189+
assert.equal(mc.labels, true);
190+
});
191+
192+
it('should not enable labels by default', () => {
193+
// aerial layer, but labels disabled
194+
mc.updateFromUrl('?labels=false');
195+
assert.equal(mc.layerId, 'aerial');
196+
assert.equal(mc.isDebug, false);
197+
assert.equal(mc.labels, false);
198+
199+
// aerial layer, but debug enabled
200+
mc.updateFromUrl('?debug');
201+
assert.equal(mc.layerId, 'aerial');
202+
assert.equal(mc.isDebug, true);
203+
assert.equal(mc.labels, false);
204+
205+
// aerial layer, labels disabled & debug enabled
206+
mc.updateFromUrl('?labels=false&debug');
207+
assert.equal(mc.layerId, 'aerial');
208+
assert.equal(mc.isDebug, true);
209+
assert.equal(mc.labels, false);
210+
211+
// debug disabled, but individual layer
212+
mc.updateFromUrl('i=abc123');
213+
assert.equal(mc.layerId, 'abc123');
214+
assert.equal(mc.isDebug, false);
215+
assert.equal(mc.labels, false);
216+
217+
// individual layer & debug enabled
218+
mc.updateFromUrl('i=abc123&debug');
219+
assert.equal(mc.layerId, 'abc123');
220+
assert.equal(mc.isDebug, true);
221+
assert.equal(mc.labels, false);
222+
});
177223
});

packages/landing/src/config.map.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class MapConfig extends Emitter<MapConfigEvents> {
6969
}
7070

7171
get isDebug(): boolean {
72-
return this.debug.debug;
72+
return this.debug.debug === true;
7373
}
7474

7575
/** Map location in WGS84 */
@@ -128,7 +128,7 @@ export class MapConfig extends Emitter<MapConfigEvents> {
128128
const config = urlParams.get('c') ?? urlParams.get('config');
129129
const layerId = urlParams.get('i') ?? style ?? 'aerial';
130130
const terrain = urlParams.get('t') ?? urlParams.get('terrain');
131-
const labels = Boolean(urlParams.get('labels'));
131+
const labels = urlParams.get('labels');
132132

133133
const projectionParam = (urlParams.get('p') ?? urlParams.get('tileMatrix') ?? GoogleTms.identifier).toLowerCase();
134134
let tileMatrix = TileMatrixSets.All.find((f) => f.identifier.toLowerCase() === projectionParam);
@@ -145,7 +145,11 @@ export class MapConfig extends Emitter<MapConfigEvents> {
145145
this.style = style ?? null;
146146
this.layerId = layerId.startsWith('im_') ? layerId.slice(3) : layerId;
147147
this.tileMatrix = tileMatrix;
148-
this.labels = labels;
148+
if (labels == null) {
149+
this.labels = layerId === 'aerial' && this.isDebug === false;
150+
} else {
151+
this.labels = labels !== 'false';
152+
}
149153

150154
if (this.layerId === 'topographic' && this.style == null) this.style = 'topographic';
151155
this.emit('tileMatrix', this.tileMatrix);

0 commit comments

Comments
 (0)