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

Eventlistener 'ClusterClick' gets removed when layer is toggled through layer control #200

Closed
annetdeboer opened this issue Jun 22, 2013 · 6 comments

Comments

@annetdeboer
Copy link

Hi all, I have had the following issue and found a workaround, but I am wondering if this would be 'the way to go'. Here it comes:
I add a new MarkerClusterGroup layer, and on this I attach the EventListener 'clusterclick'. Works like a charm. But as soon as this layer gets toggled off/on through the LeafletJS layer control, the eventlistener is removed.
I found a workaround where I now use an eventlistener to 'layeradd' and whenever this gets fired I add the 'clusterclick' listener (again). Seems a bit redundant though. Any thoughts on the matter?
Thanks in advance!
Best wishes and by the way, thanks for this great plugin!
Annet

@danzel
Copy link
Member

danzel commented Jun 23, 2013

Is this on the latest version?
Will take a look on Monday.

@annetdeboer
Copy link
Author

Hi Danzel, sorry I had not noticed the new version. Just tried the old config with the new version but that now gives me a "TypeError: this._nonPointGroup.hasLayer is not a function
...(layer.__parent && layer.__parent._group === this) || this._nonPointGroup.hasLay...
leafle...ter2.js (line 328)"

On the point where I try to add the first marker to the MarkerClusterGroup:
var m = new L.marker([lat, lon], {
title: title,
icon: i
}).addTo(iconlaag);

*the 'iconlaag' was defined as follows: iconlaag = new L.MarkerClusterGroup();
I guess there is something more going on here? :s

Thanks, Annet

p.s.: I get the same when I remove the .addTo(iconlaag) and try to add it using iconlaag.addLayer(m). Also when I remove all custumised options from the marker m and define it as being new L.marker([lat, lon]); It breaks at the point where the marker should be added to the MarkerClusterGroup.

@danzel
Copy link
Member

danzel commented Jun 23, 2013

Ah yeah. The current master of markercluster requires a master version of leaflet too.

Try grab this slightly older one which will work with 0.5:
https://github.com/Leaflet/Leaflet.markercluster/archive/b128e950d8f5d7da5b60bd0aa9a88f6d3dd17c98.zip

I'll write up a test for events now to make sure this is fixed.

danzel added a commit that referenced this issue Jun 23, 2013
danzel added a commit that referenced this issue Jun 23, 2013
@danzel
Copy link
Member

danzel commented Jun 23, 2013

Wow, thanks for reporting this one. We really didn't handle being removed from the map very well!

Should be all fixed up in the master version now, you will need a version of leaflet newer than 2013-01-21 as we rely on some of the new features (Current master should be fine).

@danzel danzel closed this as completed Jun 23, 2013
@annetdeboer
Copy link
Author

Thanks for the quick fix! Works perfect now! :o)

@ivleth
Copy link

ivleth commented Jul 8, 2013

I can confirm that the issue is solved by using the master of Leaflet.markercluster and Leaflet of today July 8th 2013.
Thanks and keep up the good work!

Regards Ingmar

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

3 participants