@mapbox-controls/language
v3.0.0
Published
Change map language
Downloads
67
Readme
📖 @mapbox-controls/language
Localize map or change dynamically language.
By default, supported languages option is the supported list by mapbox styles.
npm i @mapbox-controls/language
// set language from browser, use 'mul' as fallback
map.addControl(new LanguageControl());
// set custom language while initialization
const languageControl = new LanguageControl({
language: 'ru',
});
map.addControl(languageControl);
// or change language dynamically
languageControl.setLanguage(event.target.value);
Options
export type ControlOptions = {
supportedLanguages?: string[];
language?: string;
getLanguageKey?: (language: string) => string;
excludedLayerIds?: string[];
};
Methods
setLanguage(lang?: string | undefined): void;
- set dynamically map language