Guard syncTerrain against running before the style has loaded
This commit is contained in:
1 parent
cd02b03502
commit
17d1adedbc
1 file changed
+5
@@ -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 });
|
||||
|
||||
Reference in new issue
Block a user