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

Is eachLayer meant to work in MarkerClusterGroup? #102

Closed
cilogi opened this issue Dec 5, 2012 · 4 comments
Closed

Is eachLayer meant to work in MarkerClusterGroup? #102

cilogi opened this issue Dec 5, 2012 · 4 comments

Comments

@cilogi
Copy link

cilogi commented Dec 5, 2012

The eachLayer function doesn't seem to work in markerClusterGroup. Is this deliberate? If so is there any alternate functionality that lets me iterate over markers?

I'm writing an editor which lets you change various features of (modified) markers and one thing I need to do if a template changes is walk through and change all the markers using that template. I originally used eachLayer to do this, but it didn't work once I moved to MarkerClusterGroup. I can keep a list of the markers for each template separately of course, but it would be cleaner if Leaflet would do it for me.

@danzel danzel closed this as completed in 13e71f5 Dec 5, 2012
@danzel
Copy link
Member

danzel commented Dec 5, 2012

Have added eachChildLayer, which provides eachLayer-like behaviour.

We cannot override eachLayer as eachLayer must iterate only visible layers. LayerGroup - which MarkerClusterGroup is derived from - relies on this behaviour.

Please give it a go :)

@cilogi
Copy link
Author

cilogi commented Dec 6, 2012

Dave,

Thanks for the quick reply. I will try it out, but it will be awhile as
I'm travelling the next couple of weeks.

I find it a bit odd that eachLayer only works on visible layers. The onAdd
and onRemove functions of LayerGroup use eachLayer, so does that mean that
I can't remove invisible layers (and what is an invisible layer)?

Tim

On 5 December 2012 20:51, Dave Leaver notifications@github.com wrote:

Have added eachChildLayer, which provides eachLayer-like behaviour.

We cannot override eachLayer as eachLayer must iterate only visible
layers. LayerGroup - which MarkerClusterGroup is derived from - relies on
this behaviour.

Please give it a go :)


Reply to this email directly or view it on GitHubhttps://github.com/danzel/Leaflet.markercluster/issues/102#issuecomment-11059934.

danzel added a commit that referenced this issue Dec 6, 2012
@danzel
Copy link
Member

danzel commented Dec 6, 2012

Your comment made me go take another look and I managed to work around the issue, so you just use eachLayers like normal and it will all work :)

Invisible layers are markers you have added to a MarkerClusterGroup but they aren't currently visible on the map (either they are in a cluster or are too far off screen).
You shouldn't need to worry about whether a marker is visible or not.

@cilogi
Copy link
Author

cilogi commented Dec 6, 2012

Dave,

Thanks. That's great. The MarkerCluster plugin has made me realise how
much can be done with JS nowadays for mainstream applications. Its a
marvellous piece of work.

Tim

On 6 December 2012 00:26, Dave Leaver notifications@github.com wrote:

Your comment made me go take another look and I managed to work around the
issue, so you just use eachLayers like normal and it will all work :)

Invisible layers are markers you have added to a MarkerClusterGroup but
they aren't currently visible on the map (either they are in a cluster or
are too far off screen).
You shouldn't need to worry about whether a marker is visible or not.


Reply to this email directly or view it on GitHubhttps://github.com/danzel/Leaflet.markercluster/issues/102#issuecomment-11067951.

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