-
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
Get original data from a GeoJSONSource #1762
Comments
If you need it both as a source and as an object for further processing, you should just pass the object instead of an url to GeoJSONSource, or fetch it the second time to avoid a performance hit — sending JSON data between worker and the main thread is expensive in case of big JSON objects. I don't think we want to handle this on the API level. |
I didn't know that. Thanks!
Just so I understand the issue correctly as I'm not familiar with the inner workings of Mapbox GL: |
Yes, that's correct, but that depends on the size of GeoJSON. It's fine for smaller objects. |
Okay, thanks @mourner for the explanation, very much appreciated! |
load GeoJSON directly, then pass to Mapbox Mapbox won't share if it loads the data: mapbox/mapbox-gl-js#1762 map events only return features in the viewport; does not include all features in the geojson
When I add a GeoJSON source to my map, I can point
options.data
to an URL like so:Mapbox GL takes care of fetching my external source, which is great. But is there a way to access the original GeoJSON data for further processing outside of Mapbox GL? Something like
getData()
which returns the plain, unchanged GeoJSON object?As long as I'm not missing the obvious, right now I have to fetch the GeoJSON manually for a second time. It would be nice to circumvent this unnecessary step.
The text was updated successfully, but these errors were encountered: