Skip to content

Commit

Permalink
fix(landing): ensure the layer dropdown always showing for all outputs.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Wentao-Kuang and blacha authored Apr 21, 2024
1 parent 0f81ac3 commit 766f92b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/landing/src/components/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/landing/src/config.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class MapConfig extends Emitter<MapConfigEvents> {

/** 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 {
Expand Down

0 comments on commit 766f92b

Please sign in to comment.