kstukstu / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
0 stars 0 forks source link

Function clearMarkers break everything #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When I call 
    markerCluster.clearMarkers();
    delete markerCluster;
        markerCluster = new MarkerClusterer(map, markers); 

After these actions master clusterer stops redrawing clusters. 

Could you, please, give me a right way to clear clusters, load new data and
show it (for google map v3).

Original issue reported on code.google.com by catu...@gmail.com on 2 Jun 2010 at 2:24

Attachments:

GoogleCodeExporter commented 9 years ago
I had the same problem as well. I fixed it by only declaring my MarkerClusterer 
once during initialization:

markerCluster = new MarkerClusterer(map);

and then adding markers using a loop after clearing. Something like:

markerCluster.clearMarkers();
if(markers)
{
  for(i in markers)
  {
    markerCluster.addMarker(markers[i]);
  }
}

Hope that helps steer you in the right direction. :D

Original comment by Bobidy...@gmail.com on 7 Jun 2010 at 7:59

GoogleCodeExporter commented 9 years ago
Thanks a lot. It helped.

Original comment by catu...@gmail.com on 17 Jun 2010 at 9:09

GoogleCodeExporter commented 9 years ago
I'm not able to replicate your problem. It maybe have been fixed with recent 
releases.

Original comment by lu...@google.com on 19 Oct 2010 at 4:07

GoogleCodeExporter commented 9 years ago
Hi... Just an observation. You do not need to do this 'for', simply just use 
the 'addMarkers':

if (markers) {
    markerCluster.addMarkers(markers);
}

Original comment by fernando...@gmail.com on 13 May 2013 at 2:14