hack, javascript
MarkerClusterer clearMarkers bugfix
1 December 2009 | Comments
ATTENTION : This post started from a mistake.
Demos are updated with the correct use of clearMarkers (which is bug free).
Demos are updated with the correct use of clearMarkers (which is bug free).
(This should be a crosspost written with Carlo)
It seems that MarkerClusterer has a bug, fixed with this patch (*) written by me while I was hunting with Carlo for it on this application (now working fine): after the ajax submit and zooming out, the library was still displaying old clusters and markers, because, after destroying MarkerClusterer, the event assigned to GEvent wasn’t correctly removed.
(*) the patch is created against the r1159 version on gmaps-utility-library-dev.
This entry was posted in hack, javascript. Bookmark the permalink. ← Hanno i soldi, vogliono vivere in una zucca. Lasciali vivere in una zucca. Markerclusterer clearmarkers bug demo →
10 Comments
Hi,
is there a way to show in JGcharts the X_axis verticaly and not horizontaly?
Thanks in advance,
Dani.
Thank You.I wasted two days to debug this issue. Hope ur bug fix helps.
I modified the markerclusterer.js with this patch. but think something is missing.cant figure out where are you calling the destroy.Is it possible to get the complete updated version of js file.could not find it on gmaps-utility-library-dev.
Thanks,
Neerju
@NeerjuGupta: you can download the original js at the following uri
http://code.google.com/p/gmaps-utility-library-dev/source/browse/trunk/markerclusterer/src/markerclusterer.js
Hi,
Faced few more issues after applying above patch. I was trying to clear the markers and readd them based on some criteria.Problem was after calling ‘destroy’ it removed the listener and never added it back.So for newly added markers cluster stopped redrawing itself.have fixed the issues as follows.
3.38 @@ -375,22 +379,43 @@
3.39 * @param {Array of GMarker} markers The markers you want to add.
3.40 */
3.41 this.addMarkers = function (markers) {
3.42 -
3.43 for (var i = 0; i < markers.length; ++i) {
3.44 this.addMarker(markers[i], true);
3.45 }
3.46 this.redraw_();
3.47 + //##neerjug fixed for clearMarkers.
3.48 + if (!mcfn_ || mcfn_=== null) {
3.49 + mcfn_ = GEvent.addListener(map_, "moveend", function(){
3.50 + me_.resetViewport();
3.51 + });
3.52 + }
3.53 };
3.54
3.55 // initialize
3.56 if (typeof opt_markers === "object" && opt_markers !== null) {
3.57 this.addMarkers(opt_markers);
3.58 +
3.59 }
3.60 + // when map move end, regroup.
3.61 + //neerjug modified.it was a bug. moveend was not behaving properly after clearmarkers if fired.
3.62 +// mcfn_ = GEvent.addListener(map_, "moveend", function(){
3.63 +// me_.resetViewport();
3.64 +// });
3.65 + //###max
3.66 + this.destroy = function(){
3.67 + this.clearMarkers();
3.68 + if (mcfn_ != null) {
3.69 + GEvent.removeListener(mcfn_);
3.70 + mcfn_ = null;
3.71 + //me_ = null;
3.72 + }
3.73 +
3.74 +
3.75 + }
3.76 + //###max
3.77
3.78 – // when map move end, regroup.
3.79 – mcfn_ = GEvent.addListener(map_, "moveend", function () {
3.80 – me_.resetViewport();
3.81 – });
3.82 + //##neerjug end of fixes for clear markers.
3.83 +
3.84 }
Hi
I’m using the MarkerClusterer to display my photos. At one point I always have to completely recreate the clusterer, because the clearMarkersMarkers() method doesn’t seem to work. Searching google I found your patch. I added you patch, but It doesn’t seem to make a difference. as NeerjuGupta I don’t understand your code. You added:
... this.destroy = function() { this.clearMarkers(); GEvent.removeListener(mcfn_); mcfn_ = null; me_ = null; } ...but this.destroy get’s never called?
@simon
see here
http://www.piemonteitalia.eu/index.php?option=com_mappet
the “main” of the application is here:
http://www.piemonteitalia.eu/components/com_mappet/views/mappet/js/mappet.js
when i submit the form I invoke processJson
in function “processJson” I call
markerCluster.destroy();
I hope I have been of help to you
I just wanted to say a deep and heartfelt thanks for this patch! This issue was driving me crazy today.
Have you submitted this or a bug report to the project? The fact the documented call is not functional will likely hit others it would be great to see this fix incorporated.
@Nick
http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/
http://code.google.com/p/gmaps-utility-library-dev/issues/detail?id=196
Thanks for that additional information.
I just saw this:
http://code.google.com/p/gmaps-utility-library-dev/source/detail?r=1214
It appears the bug may have been addressed in r1214 which was just committed last week.
I’m going to check out 1214 now and see how it goes.
Cheers
2 Trackbacks
[...] (This should be a crosspost written with Massimiliano) [...]
[...] the last two posts, I described a bug but later I realized it was a false positive. There was no bug in the [...]