mirror of
https://github.com/visgl/react-map-gl.git
synced 2025-12-08 20:16:02 +00:00
18 lines
406 B
JavaScript
18 lines
406 B
JavaScript
/* global setTimeout */
|
|
export function sleep(milliseconds) {
|
|
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
}
|
|
|
|
export function waitForMapLoad(mapRef) {
|
|
return new Promise(resolve => {
|
|
const check = () => {
|
|
if (mapRef.current && mapRef.current.getMap().isStyleLoaded()) {
|
|
resolve();
|
|
} else {
|
|
setTimeout(check, 50);
|
|
}
|
|
};
|
|
check();
|
|
});
|
|
}
|