From 2f140c168ec20ac6b1f30f01af20ca62d3dcda6e Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sat, 7 Mar 2026 01:45:53 +0000 Subject: [PATCH] Add ability to handle map load late --- html/static/js/map-multipoint.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/static/js/map-multipoint.js b/html/static/js/map-multipoint.js index be87f1ec..713d830c 100644 --- a/html/static/js/map-multipoint.js +++ b/html/static/js/map-multipoint.js @@ -11,6 +11,8 @@ class MapMultipoint extends HTMLElement { // Initial render this.render(); + // Keep track of any 'on' calls to add to the map as soon as we create it. + this._preOns = []; this._map = null; this._markers = []; } @@ -72,6 +74,9 @@ class MapMultipoint extends HTMLElement { }, }); }); + for (const on of this._preOns) { + this._map.on(on.a, on.b); + } } // Initial render of component @@ -99,7 +104,11 @@ class MapMultipoint extends HTMLElement { return this._map.jumpTo(args); } on(a, b) { - return this._map.on(a, b); + if (this._map != null) { + return this._map.on(a, b); + } else { + this._preOns.push({ a: a, b: b }); + } } once(a, b) { return this._map.once(a, b);