* _loadMapLibreAsync * Load the MapLibre JS and CSS files into the document head * @return {Promise} Promise resolved when both files have been loaded
()
| 256 | * @return {Promise} Promise resolved when both files have been loaded |
| 257 | */ |
| 258 | _loadMapLibreAsync() { |
| 259 | if (this._loadPromise) return this._loadPromise; |
| 260 | |
| 261 | return this._loadPromise = new Promise((resolve, reject) => { |
| 262 | const assets = this.context.systems.assets; |
| 263 | |
| 264 | let count = 0; |
| 265 | const loaded = () => { |
| 266 | if (++count === 2) resolve(); |
| 267 | }; |
| 268 | |
| 269 | const $head = d3_select('head'); |
| 270 | |
| 271 | $head.selectAll('#rapideditor-maplibre-css') |
| 272 | .data([0]) |
| 273 | .enter() |
| 274 | .append('link') |
| 275 | .attr('id', 'rapideditor-maplibre-css') |
| 276 | .attr('rel', 'stylesheet') |
| 277 | .attr('crossorigin', 'anonymous') |
| 278 | .attr('href', assets.getAssetURL('maplibre_css')) |
| 279 | .on('load', loaded) |
| 280 | .on('error', reject); |
| 281 | |
| 282 | $head.selectAll('#rapideditor-maplibre-js') |
| 283 | .data([0]) |
| 284 | .enter() |
| 285 | .append('script') |
| 286 | .attr('id', 'rapideditor-maplibre-js') |
| 287 | .attr('crossorigin', 'anonymous') |
| 288 | .attr('src', assets.getAssetURL('maplibre_js')) |
| 289 | .on('load', loaded) |
| 290 | .on('error', reject); |
| 291 | }); |
| 292 | } |
| 293 | |
| 294 | |
| 295 | /** |
no test coverage detected