From 766f92bdfaf73747de0b64b36990f06aa57b2ff0 Mon Sep 17 00:00:00 2001 From: Wentao Kuang Date: Mon, 22 Apr 2024 11:59:06 +1200 Subject: [PATCH] fix(landing): ensure the layer dropdown always showing for all outputs. BM-1001 (#3241) #### Motivation Outputs layers not showing up when using the `i` query parameter to viewing elevations data. Cause the `Config.map.styleId` will return the empty styleId. #### Modification - Using layerId when `style` query parameter not specified. - Showing 'off' when there is no selectedSrouce for the layer dropdown. #### Checklist _If not applicable, provide explanation of why._ - [ ] Tests updated - [ ] Docs updated - [x] Issue linked in Title --------- Co-authored-by: Blayne Chard --- packages/landing/src/components/debug.tsx | 3 +-- packages/landing/src/config.map.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/landing/src/components/debug.tsx b/packages/landing/src/components/debug.tsx index 7b7a561d9..4ff1540f2 100644 --- a/packages/landing/src/components/debug.tsx +++ b/packages/landing/src/components/debug.tsx @@ -425,8 +425,7 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> { const sourceIds = this.getSourcesIds('raster'); if (sourceIds.length <= 1) return; // Get default source - const selectedSource = this.props.map.getLayer(Config.map.styleId)?.source; - if (selectedSource == null) return; + const selectedSource = this.props.map.getLayer(Config.map.styleId)?.source ?? 'off'; return debugSourceDropdown({ label: 'Layer', diff --git a/packages/landing/src/config.map.ts b/packages/landing/src/config.map.ts index f01660da8..399b4df76 100644 --- a/packages/landing/src/config.map.ts +++ b/packages/landing/src/config.map.ts @@ -108,7 +108,7 @@ export class MapConfig extends Emitter { /** Used as source and layer id in the Style JSON for a given layer ID */ get styleId(): string { - return `basemaps-${Config.map.style}`; + return Config.map.style == null ? `basemaps-${Config.map.layerId}` : `basemaps-${Config.map.style}`; } getDateRangeFromUrl(urlParams: URLSearchParams): FilterDate {