MCPcopy Create free account
hub / github.com/facebook/Rapid / _loadMapLibreAsync

Method _loadMapLibreAsync

modules/core/Map3dSystem.js:258–292  ·  view source on GitHub ↗

* _loadMapLibreAsync * Load the MapLibre JS and CSS files into the document head * @return {Promise} Promise resolved when both files have been loaded

()

Source from the content-addressed store, hash-verified

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 /**

Callers 1

startAsyncMethod · 0.95

Calls 4

dataMethod · 0.80
getAssetURLMethod · 0.80
onMethod · 0.45
enterMethod · 0.45

Tested by

no test coverage detected