Skip to content

Commit

Permalink
Make terrain and hillshade loaded for screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao-Kuang committed Jul 18, 2024
1 parent 3267a81 commit 0ed4533
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/landing/src/components/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
if (Config.map.debug['debug.screenshot']) {
async function addLoadedDiv(): Promise<void> {
// Ensure hillshade source is loaded
const hillShadeSourceId = `${HillShadePrefix}${Config.map.debug['debug.hillshade']}`;
if (Config.map.debug['debug.hillshade']) {
if (!map.isSourceLoaded(`${HillShadePrefix}${Config.map.debug['debug.hillshade']}`)) return;
if (map.getSource(hillShadeSourceId) == null) return;
if (!map.isSourceLoaded(hillShadeSourceId)) return;
}
// Ensure terrain source is loaded
if (Config.map.debug['debug.terrain']) {
if (map.getSource(Config.map.debug['debug.terrain']) == null) return;
if (!map.isSourceLoaded(Config.map.debug['debug.terrain'])) return;
}
// Ensure the attribution data has loaded
Expand All @@ -128,12 +131,11 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {

void map.on('sourcedata', (e) => {
if (e.source.type !== 'raster-dem') return;
if (e.isSourceLoaded) {
void addLoadedDiv();
}
void addLoadedDiv();
});

void map.on('idle', () => {
this.updateFromConfig();
void addLoadedDiv();
});
}
Expand Down Expand Up @@ -364,6 +366,7 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
source: hillShadeSourceId,
paint: { 'hillshade-shadow-color': '#040404' },
});
map;
}

setTerrainShown(sourceId: string | null): void {
Expand Down

0 comments on commit 0ed4533

Please sign in to comment.