Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(landing): enable labels upon first visit BM-1101 #3364

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
10 changes: 7 additions & 3 deletions packages/landing/src/config.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class MapConfig extends Emitter<MapConfigEvents> {
}

get isDebug(): boolean {
return this.debug.debug;
return this.debug.debug === true;
}

/** Map location in WGS84 */
Expand Down 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.isDebug === false;
} else {
this.labels = labels !== 'false';
}

if (this.layerId === 'topographic' && this.style == null) this.style = 'topographic';
this.emit('tileMatrix', this.tileMatrix);
Expand Down
Loading