mapbox / mapbox-gl-language

Switch language of your Mapbox GL JS style
https://mapbox.github.io/mapbox-gl-language/
BSD 3-Clause "New" or "Revised" License
198 stars 51 forks source link

Language cannot be set, if zoom is smaller than 6 when creating the map #60

Open WindLi001 opened 1 year ago

WindLi001 commented 1 year ago

I found an interesting issue.

then an English map is shown.

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.

WindLi001 commented 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.

yunchen-lee commented 1 year ago

I found same issue when creating the map. I want to set the laguage as English, but alway show some Chinese labels.