diff --git a/src/js/hillshade_control.js b/src/js/hillshade_control.js index 84fe00c7d..3f8eee0a6 100644 --- a/src/js/hillshade_control.js +++ b/src/js/hillshade_control.js @@ -30,7 +30,9 @@ export class HillshadeControl { this._button = document.createElement("button"); this._button.className = "maplibregl-ctrl-terrain"; - this._updateButton(); + Promise.resolve(map.loaded() || map.once("load")).then(() => + this._updateButton() + ); this._button.addEventListener("click", this._onClick); this._container.append(this._button);