Fix terrain "source" error being fired when using map.getStyle()
with globe view
#12163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #11553.
In order to enable draping with globe view, we mock a terrain source like this:
const mockTerrainOptions = {source: '', exaggeration: 0};
. This mocked terrain is returned in themap.getStyle()
.If a user decides to use set the map's style with
map.getStyle()
it will trigger a terrain error while validating the terrain source. It is not useful/meaningful to the user to see the mocked terrain source in the returned value frommap.getStyle()
and therefore should hide it from being returned inmap.getStyle()
. To do so, I use in thestyle.getTerrain()
to return the value of terrain in theserialize
function, which should mimic the behavior of other projections when terrain is not set (e.g. return 'undefined').Launch Checklist
mapbox-gl-js
changelog:<changelog>Fix terrain error being fired when using map.getStyle() with globe view</changelog>