Skip to content

Commit

Permalink
moved rtl plugin call to before promise resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
eo-uk committed Oct 13, 2023
1 parent d7ce6a1 commit c421771
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/layer/format/maplibre.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ async function MaplibreGL() {

maplibregl = imports[0]

// Avoid loading RTL Text Plugin twice, else it will error
if (!["deferred", "loaded"].includes(maplibregl.getRTLTextPluginStatus())) {
maplibregl.setRTLTextPlugin(
'https://unpkg.com/@mapbox/[email protected]/mapbox-gl-rtl-text.min.js',
null,
true // Lazy load the plugin
);
}

resolve()
})
.catch(error => {
Expand All @@ -34,14 +43,6 @@ async function MaplibreGL() {

await promise

// Avoid loading RTL Text Plugin twice, else it will error
if (!["deferred", "loaded"].includes(maplibregl.getRTLTextPluginStatus())) {
maplibregl.setRTLTextPlugin(
'https://unpkg.com/@mapbox/[email protected]/mapbox-gl-rtl-text.min.js',
null,
true // Lazy load the plugin
);
}

return new maplibregl.Map(...arguments);
}
Expand Down

0 comments on commit c421771

Please sign in to comment.