-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
How to get raw geojson data from addSource request: follow-up #8350
Comments
I don't think the raw GeoJSON is stored anywhere. Assuming it gets converted to vector tiles then thrown away. If you need to access it (which is a common need), you'll need to fetch it yourself. I find a useful pattern is:
|
You can try this |
It's probably returning an empty array because it didn't finish loading. I think you have to subscribe to some event before doing
The problem is that it's stored on the Web Worker side, not on the main thread, so there's no easy way to fetch it. Anyway, I'd recommend that you fetch your GeoJSON in the app in addition to loading it as a GL JS GeoJSON source. That removes any gotchas / difficulties from this case. |
Hello - thanks for the follow-up on the previous question:
#8333
I tried this:
but unfortunately it's returning an empty array.
@mourner is the GeoJSON data stored somewhere else (?), even as a private variable?
@planemad the data is visible on the default view of the map - the code was taken from the sweetgreens example, and I'm just passing the data from the server instead of hard-coding it. Thanks!
The text was updated successfully, but these errors were encountered: