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

Markerclusterer clearmarkers bug #196

Open
GoogleCodeExporter opened this issue Aug 1, 2015 · 1 comment
Open

Markerclusterer clearmarkers bug #196

GoogleCodeExporter opened this issue Aug 1, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Carlo and I, working together on an application, have met a problem hard to 
isolate and solve.
Markerclusterer library (of gmaps-utility-library-dev) has a bug.

Let me try to explain the problem.

Each cluster has an event associated with it (in fact, the click event
on the cluster triggers the "zoom in" on the map and the cluster
splits itself in markers or smaller clusters).

When, from the outside (for example, within a form), I clean the map -
map.clearOverlays(); - and then I refill it with a new search, I'm not
able anymore to destroy the clusters.

It seems the clusters are disappeared but, in fact, zooming in or out,
they come back.

Look at the three pictures in the post.
The first and the second picture shows the clusters correctly.
The third picture instead shows the clusters of the second
search AND the ones of the first (after having done
"zoom out").

The whole thing is due to a bug in the JavaScript garbage collection
(I suppose...).

The ojbect has been "subscribed" to an event. The object is destroyed
but after the first trigger of that event, the object come back.

To fix this strange bug (it's even hard to reproduce it, without a
form!) it's mandatory to provide to the markerclusterer library a
method to correctly destroy the clusters.

The patch (the diff file has been written again the 1159 revision)
adds the destroy method.
Before doing a new search, it is required to call

map.clearOverlays();

AND

markerCluster.destroy();

where markerCluster is your instance of MarkerClusterer(map, points);

The destroy() method calls:
this.clearMarkers();
GEvent.removeListener(mcfn_);
mcfn_ = null;
me_ = null;

I reported the bug to the developers with a demo of the bug itself
(and a second demo with the fix). I hope my patch could help people to
not get mad on it.

See here for the description of the bug:
http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/

And here for test the bug and the fix
http://maxb.net/scripts/markerclusterer/bug.html
http://maxb.net/scripts/markerclusterer/fix.html
http://perassi.org/quickhacks/mkp/mk.diff

Thank you.

Original issue reported on code.google.com by [email protected] on 15 Mar 2010 at 2:01

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

No branches or pull requests

1 participant