Open WindLi001 opened 1 year ago
Furthermore, I find this issue only happened when I set projection to global and zoom smaller than 6. That is,
map.current = new mapboxLibrary.Map({
**zoom: 5,**
container: mapContainer.current,
style: isDarkMode()
? 'mapbox://styles/mapbox/dark-v10'
: 'mapbox://styles/mapbox/streets-v11',
...mapboxOptions,
})
and
const { mapContainer, mapboxMap, mapboxToken } = useMapboxMap({
configureMapbox: configureMapbox({ mapboxData, dispatchMarkerMedia }),
mapboxOptions: {
**projection: {
name: 'globe',
},**
},
})
, and then
map.current.addControl(new MapboxLanguage({defaultLanguage: 'zh-Hans'}));
an English map but not Chinese map is shown.
I found same issue when creating the map. I want to set the laguage as English, but alway show some Chinese labels.
I try this way but not work, still some Chinese labels shown at left hand side
map.setLayoutProperty('country-label', 'text-field', ['get', 'name_en'])
and then I found that there are different labels, all of them have to set as English.
let labels = ['country-label', 'state-label',
'settlement-label', 'settlement-subdivision-label',
'airport-label', 'poi-label', 'water-point-label',
'water-line-label', 'natural-point-label',
'natural-line-label', 'waterway-label', 'road-label'
];
labels.forEach(label => {
map.setLayoutProperty(label, 'text-field', ['get', 'name_en']);
});
I found an interesting issue.
If I create a map with zoom isn't set (that is, zoom is default), or is set to a value smaller than 6, and then set the language to Chinese,
then an English map is shown.
If I create a map with zoom is set to a value bigger than or equal to 6, and then set the language to Chinese,
then a Chinese map is shown.
The code above is a part of project photoview [https://github.com/photoview/photoview], and in the ui/src/components/mapbox/MapboxMap.tsx. You can find the context there.