From 17d1adedbc5b38b6cb45a08ebed64e099f11534c Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Sat, 12 Sep 2026 13:27:53 +0200 Subject: [PATCH] Guard syncTerrain against running before the style has loaded --- public/js/overlays.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/overlays.js b/public/js/overlays.js index c032f5a..06549ac 100644 --- a/public/js/overlays.js +++ b/public/js/overlays.js @@ -100,6 +100,11 @@ class HillshadeControl { // showing raised terrain needs both "tilted enough to see it" and "the // DEM source this checkbox controls is actually loaded". syncTerrain(pitched) { + // setLight/setTerrain throw if the style isn't loaded yet — called + // synchronously from map.js's setOverlaysControl during page init, + // before the first style.load; that listener re-invokes this once it + // actually is loaded, so bailing here just skips the premature call. + if (!this._map.isStyleLoaded()) return; const terrainOn = pitched && this._active && this._map.getSource(HILLSHADE_ID); if (terrainOn) { this._map.setTerrain({ source: HILLSHADE_ID, exaggeration: 3 });