From 1868338b162f7167b25604a25e5a5a21e432c301 Mon Sep 17 00:00:00 2001 From: Josh Lee Date: Wed, 15 Jan 2025 14:13:35 -0500 Subject: [PATCH] Fix race in hillshade control initialization (#1188) --- src/js/hillshade_control.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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);