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

No method to get all markers back #5821

Closed
SoundBot opened this issue Dec 6, 2017 · 4 comments
Closed

No method to get all markers back #5821

SoundBot opened this issue Dec 6, 2017 · 4 comments

Comments

@SoundBot
Copy link

SoundBot commented Dec 6, 2017

Seems there is no good way to get all markers back. This might be useful if you want to clear the map or apply something to all markers.

@jfirebaugh
Copy link
Contributor

That's correct, and by design to keep the API and memory use small. If you need to remove all markers at once, you can keep an array of the markers you've added, and call remove on each of them.

@SoundBot
Copy link
Author

SoundBot commented Dec 6, 2017

This requires to store a state, which usually introduces unnecessary complexity in large applications.

@ralexrdz
Copy link

ralexrdz commented Jan 9, 2018

I'm using a Polymer 2 Component for Mapbox-GL
I have Mapbox objects and functions within each component. [[map]]

<mapbox-gl map="[[map]]">
 <template is="dom-repeat" items="[[markers]]">
    <mapbox-gl-marker ... ></mapbox-gl-marker>
 </template>
</mapbox-gl>

Beacuse of the way it adds markers inside a dom-repeat,
I don't have an array on which I could store the Mapbox Marker objects.

here other threat

Is there a way similar to

map.styles._layers // I could not found the markers in here

where I can see the marker references?

I would like to remove a single marker from an array.
Thanks!

@mollymerp
Copy link
Contributor

@ralexrdz per #5821 (comment) we don't store references for markers

by design to keep the API and memory use small.

I think you'll have to make the change in the Polymer component if you want to store marker references.

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

4 participants