Skip to content

Commit

Permalink
Make sure map is loaded for screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao-Kuang committed Jul 17, 2024
1 parent eaa7a5d commit 7cac2a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/landing/src/components/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {

if (Config.map.debug['debug.screenshot']) {
async function addLoadedDiv(): Promise<void> {
if (!map.loaded()) return;
// Ensure the attribution data has loaded
await MapAttrState.getCurrentAttribution();
await new Promise((r) => setTimeout(r, 250));
Expand All @@ -117,7 +118,7 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
loadedDiv.style.height = '1px';
document.body.appendChild(loadedDiv);
}
void map.once('idle', () => {
void map.on('idle', () => {
void addLoadedDiv();
});
}
Expand Down

0 comments on commit 7cac2a8

Please sign in to comment.