Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: terrain: terrain is missing required property "source" when use projection: "globe" ! #55

Open
DennisGuo opened this issue Jul 14, 2022 · 2 comments

Comments

@DennisGuo
Copy link

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 !

@leungMr
Copy link

leungMr commented Jul 21, 2022

the same problem happened !!!

@hqh15
Copy link

hqh15 commented Nov 16, 2022

Everyone, I I solved it.

const map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/satellite-streets-v11',
  zoom: 1.8,
  center: [118, 40]
})

const language = new MapboxLanguage({
  defaultLanguage: 'zh-Hans'
})
map.addControl(language)

map.on('load', () => {
  map.setStyle(
    Object.assign({}, map.getStyle(), { projection: { name: 'globe' } })
  )
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants