How to get english content from esri reverse geocode run in JavaScript

27 Views Asked by At

I'm trying to show on a map the city where I've clicked on the LeafLet map. This work but the city name is showed in global language, for example if I click over Rome I get "Roma". I've already tried to set .language("en") but noting changes. So I'm looking for a way to get an English response.

I use ESRI API for the reverse geocoding and everything work but I get global language results. Here an example: Example image of the map after I click it

And I would like to get it in English("Rome" not "Roma"). I tried to set English as a parameter in the function but nothing changes:

L.esri.Geocoding.reverseGeocode({ apikey: apiKey, language: "en" })
        .latlng(e.latlng)

         // what I tried. Also in the first line
        .language("en")
        .run(async function (error, result) {
                if (error) return;
                markerArrivo.setLatLng(result.latlng);     
                markerArrivo.bindPopup(`<b> Arrivo </b><p>${result.address.Subregion}</p>`).openPopup();

                // here I want the Subregion in English
                cittaVoloArrivo.value = result.address.Subregion;
                
                ...

                } else {
                    console.log("errore: "+risposta.status);
                }
            }
    );

And here the part that calls the function with the esri request:

        function initialize(){
            map = L.map("map").setView([41.8931, 12.4828], 9);
            L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                attribution: '© OpenStreetMap contributors'
            }).addTo(map);

            ...

            // Esri API
            const apiKey = "";

            // here, onClick()
            map.on('click', function(e) {
                onClick(e, apiKey);
            });
        }
0

There are 0 best solutions below