Search code examples
javascriptinternationalizationhere-api

Maps API for Javascript - Change the labels of the city names


My problem is that some Polish cities on the map have names in English. Even when I set

const ui = H.ui.UI.createDefault(HEREmap, defaultLayers, 'pl-PL');

the map still displays them in English. For example: Karków is displayed as Cracow. It's not wrong name, but I want to provide to my users a proper i18n experience. Is there any way to translate those names? Or is it up to Here Maps to provide the names and I can't do anything about it?


Solution

  • The language argument in H.ui.UI.createDefault is for setting the language in the default UI components, for example in the layer switcher component.

    For the map data, you can take advantage of the lg property in the call to platform.createDefaultLayers, as below:

    let defaultLayers = platform.createDefaultLayers({
       lg: 'pl' // set language to Polish
    });