diff options
author | andre-dietrich <dietrich@ivs.cs.uni-magdeburg.de> | 2019-08-09 14:38:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-09 14:38:04 +0200 |
commit | 8aac10c699f0c678f62bffc9bb3457618bc1c62f (patch) | |
tree | 84de62474c1326b2278dad7556395e4b56fc85f6 | |
parent | 09249b8f3e88e70fc78a7d1f8b91e89c5962661b (diff) |
fixing error "style is not done loading"
a little modification according to the following suggestion :
https://bl.ocks.org/malwoodsantoro/43bba1d03a8d22c10b3e9943eb0c55d1
-rw-r--r-- | src/js/main.js | 16 |
1 files changed, 10 insertions, 6 deletions
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; } |