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

Fix terrain "source" error being fired when using map.getStyle() with globe view #12163

Merged
merged 4 commits into from
Aug 22, 2022

Conversation

avpeery
Copy link
Contributor

@avpeery avpeery commented Aug 12, 2022

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 the map.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 from map.getStyle() and therefore should hide it from being returned in map.getStyle(). To do so, I use in the style.getTerrain() to return the value of terrain in the serialize function, which should mimic the behavior of other projections when terrain is not set (e.g. return 'undefined').

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Fix terrain error being fired when using map.getStyle() with globe view</changelog>

@avpeery avpeery linked an issue Aug 12, 2022 that may be closed by this pull request
@avpeery avpeery marked this pull request as ready for review August 12, 2022 14:33
@avpeery avpeery requested a review from ansis August 12, 2022 14:36
Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall direction of this is good, but we shouldn't change the behavior of the public map.getTerrain(). It's currently documented as

Returns the terrain specification or null if terrain isn't set on the map.`

We should maintain that behavior

@avpeery avpeery requested a review from ansis August 15, 2022 21:02
@avpeery avpeery merged commit d45dcaf into main Aug 22, 2022
@avpeery avpeery deleted the avpeery/set-style-clean-up branch August 22, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

map.setStyle may result in error when used with globe projection
2 participants