Skip to content

Commit

Permalink
feat(landing): update logic to show labels by default for aerial layer
Browse files Browse the repository at this point in the history
  • Loading branch information
tawera-manaena committed Oct 29, 2024
1 parent e702c7e commit 15acc70
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
46 changes: 46 additions & 0 deletions packages/landing/src/__tests__/map.config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
8 changes: 6 additions & 2 deletions packages/landing/src/config.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MapConfig extends Emitter<MapConfigEvents> {
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);
Expand All @@ -145,7 +145,11 @@ export class MapConfig extends Emitter<MapConfigEvents> {
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);
Expand Down

0 comments on commit 15acc70

Please sign in to comment.