Fix Mapbox map RTL support - Fix #1391 (#1393)

Load Mapbox RTL plugin when facing RTL language on the map.
Load the plugin lazy, so it will not affect current other languages' performance.
This commit is contained in:
Haim Kastner 2021-06-29 01:39:43 +03:00 committed by GitHub
parent 1a78bc7052
commit c69dd1a32d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,6 +272,14 @@ export default {
}).catch(() => this.loading = false);
},
renderMap() {
// In case of facing RTL language on the map, this plugin will be fetched (only by lazy!) and will set RTL properly support.
// See mapbox documentation here https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-rtl-text/
mapboxgl.setRTLTextPlugin(
'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js',
null,
true // Lazy load the plugin
);
this.map = new mapboxgl.Map(this.options);
this.map.addControl(new mapboxgl.NavigationControl({showCompass: true}, 'top-right'));