-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Description
setConfigProperty('basemap', 'language', ...) silently does nothing in mapbox-gl v3.18.1 with the Standard style (mapbox://styles/mapbox/standard). The call succeeds without error, but getConfigProperty('basemap', 'language') returns null and the map labels remain in the default language.
The working API is map.setLanguage() (or the language constructor option), but this isn't obvious from the current documentation.
Steps to reproduce
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/standard',
});
map.on('load', () => {
// This silently does nothing:
map.setConfigProperty('basemap', 'language', 'ko');
console.log(map.getConfigProperty('basemap', 'language')); // null
console.log(map.getStyle().imports[0].schema); // undefined
console.log(map.getStyle().imports[0].config); // undefined
// This works:
map.setLanguage('ko'); // labels switch to Korean
});Debug findings
| API | Result |
|---|---|
setConfigProperty('basemap', 'language', 'ko') |
No error, but getConfigProperty returns null. Labels stay English. |
new Map({ config: { basemap: { language: 'ko' } } }) |
Silently ignored. |
map.setLanguage('ko') |
Works. Labels switch to Korean. |
map.getStyle().imports[0].schema |
undefined (basemap has no config schema) |
Documentation gap
The following docs reference setConfigProperty or the config constructor option for changing Standard style language, which doesn't work:
- https://docs.mapbox.com/help/dive-deeper/change-language/ — references
setConfigPropertyfor Standard style - https://docs.mapbox.com/mapbox-gl-js/guides/standard-style/ — shows
config.basemap.languagepattern
The working APIs (map.setLanguage() / new Map({ language: 'ko' })) were noted in #12950 but aren't prominent in the main docs.
Expected behavior
Either:
setConfigProperty('basemap', 'language', ...)should work as documented, or- The docs should clearly reference
map.setLanguage()as the correct API for Standard style
Environment
- mapbox-gl: 3.18.1
- Style:
mapbox://styles/mapbox/standard - Browser: Chrome (macOS)
Reactions are currently unavailable