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

replace symbol/marker when clicked on it #3021

Closed
uhuru-be opened this issue Aug 17, 2016 · 6 comments
Closed

replace symbol/marker when clicked on it #3021

uhuru-be opened this issue Aug 17, 2016 · 6 comments

Comments

@uhuru-be
Copy link

Hello,
I have a map where symbols ("markers") are added to a symbol layer using a geojson source. When moving over a marker (or clicking on it) a little popup is shown with a title, photo and description.

Now, I would like to replace the symbol when user clicks on it, so that the user sees instantly which symbols he has already checked.. What is the best way to accomplish this ?

@mourner
Copy link
Member

mourner commented Aug 17, 2016

Currently the only way to hide the symbol in this case is to remove it from the GeoJSON source and call setData again. We're investigating a way to accomplish this more efficiently, captured in #200.

@mourner mourner closed this as completed Aug 17, 2016
@mourner
Copy link
Member

mourner commented Aug 17, 2016

Alternative you can try using the new DOM markers functionality (mapboxgl.Marker).

@uhuru-be
Copy link
Author

It's not very clear to me when to use the symbol layer functionality and when to use the mapboxgl.Marker functionality. What are the odds and benefits of each method ?

It would be nice to be able to change the symbol of a GeoJSON point in the future.

@mourner
Copy link
Member

mourner commented Aug 17, 2016

@uhuru-be general rule of thumb is to use a symbol layer when you have tons of points that don't change often, and to use HTML markers when you have a few points that are animated/changed frequently or need the rich HTML styling.

@uhuru-be
Copy link
Author

Thanks. Then I guess I stick to the symbol layer because some maps have hundreds of symbols and wait for the new feature.

@mourner
Copy link
Member

mourner commented Aug 17, 2016

@uhuru-be DOM markers are OK for 100-200 markers. It becomes a performance problem when it's 500 or more.

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

2 participants