mapbox / mapbox/mapbox-gl-language
Error: terrain: terrain is missing required property "source" when use projection: "globe" !
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 204
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
When I use {projection: "globe"} to init map will cause th error .
const map = new mapboxgl.Map({
container: "map", // container ID
style: "mapbox://styles/mapbox/dark-v10", // style URL
center: [106.55, 29.57], // starting position [lng, lat]
zoom: 2, // starting zoom
projection: "globe", // display the map as a 3D globe
});
map.addControl(
new MapboxLanguage({
defaultLanguage: "zh-Hans",
})
);
The error info
Error: terrain: terrain is missing required property "source"
at Object.Mi [as emitValidationErrors] (validate_style.js:13:41)
at Ht (style.js:57:5)
at ei.setState (style.js:647:13)
at Map._updateDiff (map.js:1887:28)
at Map._diffStyle (map.js:1881:18)
at Map.setStyle (map.js:1822:18)
at MapboxLanguage._initialStyleUpdate (index.js:141:13)
at Map.fire (evented.js:129:26)
at ei.fire (evented.js:144:24)
at ei._load (style.js:355:14)
if i do not use {projection: "globe"} , it work find !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.js at MapboxLanguage._initialStyleUpdate, then trace the style update through map.js, style.js, and validate_style.js. Reproduce the error with projection set to "globe" and verify that language switching no longer produces the missing terrain source validation error.
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
- 35/100