Skip to content

Commit f616cf7

Browse files
committed
fix: allow layer replacement while tiles are loading
1 parent 37fe87f commit f616cf7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ const map = new maplibregl.Map({
2626

2727
map.addControl(new maplibregl.NavigationControl(), "bottom-right");
2828

29+
let mapReady = false;
30+
2931
const { getState } = initControls((state) => {
30-
if (map.isStyleLoaded()) {
32+
if (mapReady) {
3133
updateLayer(map, state);
3234
updateLegend(state);
3335
}
3436
});
3537

3638
map.on("load", () => {
39+
mapReady = true;
3740
map.setProjection({ type: "globe" });
3841
map.setSky({
3942
"sky-color": "#0d1117",

0 commit comments

Comments
 (0)