From 0ed4533668dd359230c7a23ca05328336ba2be1f Mon Sep 17 00:00:00 2001 From: Wentao Kuang Date: Thu, 18 Jul 2024 16:07:27 +1200 Subject: [PATCH] Make terrain and hillshade loaded for screenshot --- packages/landing/src/components/debug.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/landing/src/components/debug.tsx b/packages/landing/src/components/debug.tsx index bff0cd599..fc38d07f7 100644 --- a/packages/landing/src/components/debug.tsx +++ b/packages/landing/src/components/debug.tsx @@ -108,11 +108,14 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> { if (Config.map.debug['debug.screenshot']) { async function addLoadedDiv(): Promise { // 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 @@ -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(); }); } @@ -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 {