Skip to content

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

@WindLi001

Description

@WindLi001

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,
    map.current = new mapboxLibrary.Map({
      zoom: 5,
      container: mapContainer.current,
      style: isDarkMode()
        ? 'mapbox://styles/mapbox/dark-v10'
        : 'mapbox://styles/mapbox/streets-v11',
      ...mapboxOptions,
    })

    map.current.addControl(new MapboxLanguage({defaultLanguage: 'zh-Hans'}));

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,
    map.current = new mapboxLibrary.Map({
      zoom: 6,
      container: mapContainer.current,
      style: isDarkMode()
        ? 'mapbox://styles/mapbox/dark-v10'
        : 'mapbox://styles/mapbox/streets-v11',
      ...mapboxOptions,
    })

    map.current.addControl(new MapboxLanguage({defaultLanguage: 'zh-Hans'}));

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions