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

map.setStyle may result in error when used with globe projection #11553

Closed
karimnaaji opened this issue Feb 25, 2022 · 10 comments · Fixed by #11942 or #12163
Closed

map.setStyle may result in error when used with globe projection #11553

karimnaaji opened this issue Feb 25, 2022 · 10 comments · Fixed by #11942 or #12163
Assignees
Labels

Comments

@karimnaaji
Copy link
Contributor

From @stevage in #10784 (comment):

After setting the globe projection, when I add a GeoJSON source, I weirdly get:

Error: terrain: terrain is missing required property "source"

Adding terrain (with a source) made the error go away.

version 2.8.0-alpha.1

@avpeery
Copy link
Contributor

avpeery commented Mar 2, 2022

@stevage Thanks so much for reporting this issue in #10784! I haven't been able to reproduce the error yet (though I suspect it's coming from this conditional). Are you setting globe view in the map parameters, and using addSource to add a geoJSON source once map is loaded?

@avpeery avpeery self-assigned this Mar 2, 2022
@stevage
Copy link
Contributor

stevage commented Mar 3, 2022

Are you setting globe view in the map parameters

Yes. (As opposed to with setProjection)

and using addSource to add a geoJSON source once map is loaded?

Yes.

@stevage
Copy link
Contributor

stevage commented Mar 3, 2022

Interesting, I can't reproduce it now either, with the same codebase. I don't know what I would have changed that made a difference, but something, apparently.

@stevage
Copy link
Contributor

stevage commented Mar 3, 2022

Hmm, it's intermittently reproducible. Great.

http://mapswell.site44.com/geohash-map/#globe-bug&center=4.39/-45.63/143.89

image

@stevage
Copy link
Contributor

stevage commented Mar 3, 2022

Ah, I'm guessing it has something to do with the maybe strange way I manipulate the map style to add styles and layers, using map-gl-utils, which calls map.setStyle() rather than map.addSource().

@avpeery
Copy link
Contributor

avpeery commented Mar 21, 2022

@stevage Ah so this error might be specific to your set-up. Just to be sure, (if you're still experiencing this error), can you provide a minimal code reproduction of this issue in jsbin or codepen? Thanks!

@karimnaaji
Copy link
Contributor Author

I'll close this issue as stale as we have no repro and haven't seen this issue since then, but feel free to reopen if this issue is still visible in the latest beta we published!

@avpeery
Copy link
Contributor

avpeery commented May 19, 2022

I was able to consistently reproduce the error mentioned in this issue. Click map to toggle between a mercator map with dark style and globe view set in a style. After third click, I receive the same error terrain is missing required property "source". Reopening as I can consistently reproduce it.
https://codepen.io/avpeery/pen/JjpJjQW

@karimnaaji
Copy link
Contributor Author

@avpeery I'm reopening this issue as I've been able to reproduce this issue from latest main with the following:

evented.js:150 Error: terrain: terrain is missing required property "source"
    at Object.emitValidationErrors (validate_style.js:13)
    at emitValidationErrors (style.js:57)
    at Style.setState (style.js:647)
    at Map._updateDiff (map.js:1888)
    at Map._diffStyle (map.js:1882)
    at Map.setStyle (map.js:1823)
    at <anonymous>:1:5

@karimnaaji karimnaaji reopened this Jun 14, 2022
@karimnaaji karimnaaji changed the title Adding a GeoJSON source after setting the map to globe view result in error map.setStyle may result in error when used with globe projection Jun 14, 2022
@karimnaaji
Copy link
Contributor Author

Another test case that could be used as a way to prevent regressions on the potential fix when we address that:

  • Start with a map in mercator
  • map.setStyle(Object.assign({}, map.getStyle(), {projection: {name: 'globe'}})) -> no error
  • map.setStyle(Object.assign({}, map.getStyle(), {projection: {name: 'globe'}})) -> error Error: terrain: terrain is missing required property "source"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment