mapbox / mapbox/mapbox-gl-language

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

Open
#60 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
204
Forks
51
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the Mapbox.Map and MapboxLanguage setup shown in the report, including the default language zh-Hans at zoom values below and above 6. Review the language-control behavior against the map initialization sequence; the reported reference context is ui/src/components/mapbox/MapboxMap.tsx in photoview. Done means Chinese labels appear when the map is created with a zoom below 6.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.