Esri/esri-leaflet-vector

Add a static "setRTLTextPlugin" method

gowin20 opened this issue · 5 comments

Describe the problem

As outlined in #204, right-to-left languages such as Arabic currently display backwards in Esri Leaflet Vector. Since this plugin depends on maplibre, the fix is to call maplibregl.setRTLTextPlugin(); a top-level static maplibre method. This is not currently possible for Esri Leaflet Vector users to do, so we need to expose this setRTLTextPlugin method.

Describe the proposed solution

I would like to add a top-level static method called setRTLTextPlugin to this library that simply calls the equivalent maplibre method. This would mirror the functionality of maplibre and would make it easier for users to understand why they need to pass a Mapbox plugin to their Leaflet library to display a map in Arabic.

Alternatives considered

An alternative is to make the setRTLTextPlugin method a member of VectorBasemapLayer, but I believe making it a top-level static method is the best choice as that most closely mirrors maplibre.

Additional Information

No response

Resolved in #207. Thanks @gowin20!

Resolved in #207. Thanks @gowin20!

This Library module still doesn't use setRTLTextPlugin

declare module 'esri-leaflet-vector' {
export function vectorBasemapLayer (key: any, options: any): any;
export var VectorBasemapLayer: any;
export function vectorTileLayer (key: any, options: any): any;
export var VectorTileLayer: any;
export function maplibreGLJSLayer (options: any): any;
export var MaplibreGLJSLayer: any;
}

I am using esri-leaflet-vector latest version.

Hi @OwaisNadeemCentric please try with the newly-released v4.2.2: https://github.com/Esri/esri-leaflet-vector/releases/tag/v4.2.2

Example is here: https://github.com/Esri/esri-leaflet-vector/blob/master/examples/rtl-language.html

Hi @gavinr-maps
Now in latest version v4.2.2 the RTLTextPlugin is working but there is still one more problem.

we need this method as well getRTLTextPluginStatus() to check the status of the plugin if it is already loaded or not otherwise you will get the following error if we call RTLTextPlugin multiple times.

ERROR Error: setRTLTextPlugin cannot be called multiple times.

Hi @OwaisNadeemCentric please try with the newly-released v4.2.2: https://github.com/Esri/esri-leaflet-vector/releases/tag/v4.2.2
Example is here: https://github.com/Esri/esri-leaflet-vector/blob/master/examples/rtl-language.html

Hi @gavinr-maps Now in latest version v4.2.2 the RTLTextPlugin is working but there is still one more problem.

we need this method as well getRTLTextPluginStatus() to check the status of the plugin if it is already loaded or not otherwise you will get the following error if we call RTLTextPlugin multiple times.

ERROR Error: setRTLTextPlugin cannot be called multiple times.

A potential solution for this error is to ensure that you call the getRTLTextPlugin function only at the application's root level. Otherwise, you may encounter an error.