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

Modifying GeoJSON source #1954

Closed
luixo opened this issue Jan 20, 2016 · 7 comments
Closed

Modifying GeoJSON source #1954

luixo opened this issue Jan 20, 2016 · 7 comments

Comments

@luixo
Copy link

luixo commented Jan 20, 2016

I'm building an app with dynamic markers. My first attempt to update them was just removing layer & source and adding new ones, but the view was flickering on each update.
Then I found a setData method for source, but it throws with an error: Uncaught DataCloneError: Failed to execute 'postMessage' on 'Worker': An object could not be cloned.
I made an example: https://jsfiddle.net/mr0pzv5c/

@lucaswoj
Copy link
Contributor

map.getSource('route').setData(source);

You're supposed to pass GeoJSON to setData, not an instance of GeoJSONSource.

@luixo
Copy link
Author

luixo commented Jan 21, 2016

Thanks! Is there a way to add data instead of overwriting it?

@mcwhittemore
Copy link
Contributor

@luixo, not currently. Maybe in the long term. Until then we're working on try to make adding faster.

@shuoch
Copy link

shuoch commented Mar 7, 2018

I'm strangely getting the opposite issue, where setData is adding new points on top of old points instead of the desired behavior of overwriting. Any pointers?

@lokcon
Copy link

lokcon commented Aug 16, 2018

I just stumbled upon this but looks like an API token is pasted in the jsfiddle.

@luixo
Copy link
Author

luixo commented Aug 16, 2018

I just stumbled upon this but looks like an API token is pasted in the jsfiddle.

Thank you. The token in the fiddle is already invalidated.

@kirillegorov-dev
Copy link

kirillegorov-dev commented May 27, 2019

I'm strangely getting the opposite issue, where setData is adding new points on top of old points instead of the desired behavior of overwriting. Any pointers?

@shuoch can you reproduce such behaviour?

I think some feature with setData for new points over old will be awesome also. (I mean this #1954 (comment)). cc @mcwhittemore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants