hack, javascript

MarkerClusterer clearMarkers bugfix

12.01.09 | 8 Comments

(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.

Popularity: 30% [?]

7 Comments

  1. Dani
    Posted 9 December 2009 at 12:02 | Permalink

    Hi,
    is there a way to show in JGcharts the X_axis verticaly and not horizontaly?
    Thanks in advance,
    Dani.

  2. Posted 15 December 2009 at 00:03 | Permalink

    Thank You.I wasted two days to debug this issue. Hope ur bug fix helps.

  3. Posted 15 December 2009 at 00:30 | Permalink

    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

  4. Posted 15 December 2009 at 09:51 | Permalink

    @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

  5. Posted 15 December 2009 at 19:45 | Permalink

    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 }

  6. Posted 7 January 2010 at 20:08 | Permalink

    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?

  7. Posted 15 January 2010 at 11:28 | Permalink

    @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

One Trackback

  1. By MarkerClusterer clearMarkers bugfix on 1 December 2009 at 15:36

    [...] (This should be a crosspost written with Massimiliano) [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*
© 2010 Massimiliano Balestrieri | Thanks, WordPress | Sandbox theme | Standards Compliant XHTML & CSS | RSS Posts & Comments