Skip to content

Commit

Permalink
Ensure terrain source loaded as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao-Kuang committed Jul 17, 2024
1 parent 5104551 commit 3267a81
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/landing/src/components/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
if (Config.map.debug['debug.hillshade']) {
if (!map.isSourceLoaded(`${HillShadePrefix}${Config.map.debug['debug.hillshade']}`)) return;
}
// Ensure terrain source is loaded
if (Config.map.debug['debug.terrain']) {
if (!map.isSourceLoaded(Config.map.debug['debug.terrain'])) return;
}
// Ensure the attribution data has loaded
await MapAttrState.getCurrentAttribution();
await new Promise((r) => setTimeout(r, 250));
Expand All @@ -121,11 +125,17 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
loadedDiv.style.height = '1px';
document.body.appendChild(loadedDiv);
}

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

void map.on('idle', () => {
void addLoadedDiv();
});
}
});
};
Expand Down

0 comments on commit 3267a81

Please sign in to comment.