From 5e78c8d4bd8527d2b0cd38022ab414eb9545e6d5 Mon Sep 17 00:00:00 2001 From: andre-dietrich Date: Fri, 9 Aug 2019 14:38:04 +0200 Subject: fixing error "style is not done loading" a little modification according to the following suggestion : https://bl.ocks.org/malwoodsantoro/43bba1d03a8d22c10b3e9943eb0c55d1 --- src/js/main.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/js/main.js b/src/js/main.js index e5112fb..61054cc 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -255,12 +255,16 @@ export function registerCustomElement(settings) { this._eventRegistrationQueue = {}; options.onMount(this._map, this); if (commandRegistry[this.id]) { - this._map.on("load", () => { - var cmd; - while ((cmd = commandRegistry[this.id].shift())) { - cmd(this._map); - } - }); + function onStyleData(){ + if(map.isStyleLoaded()) { + var cmd; + while ((cmd = commandRegistry[this.id].shift())) { + cmd(this._map); + } + map.off('data', onStyleData) + } + }; + this._map.on("data", onStyleData); } return this._map; } -- cgit v1.2.3