Reputation: 516
I used google map api in my project with cluster (MarkerClusterer)
var markers=[];
for(var i=0;i<1000;i++)
{ //create marker
markers.push(marker):
}
markerclusterer = new MarkerClusterer(map, markers);
// then .. in another part .. i do .
for(var j=0;j<200;j++)
{
markers[j].setVisible(false);
}
markerclusterer.draw();
the problem ::
its hide the 200 markers but in cluster icon its still ..
i mean .. ( if i calculate the numbers shown in cluster icon =1000) . but actually 800 markes is visible and 200 are hidden.)
how to make the cluster icon =800 only. ..thnx
Upvotes: 1
Views: 7915
Reputation: 20492
when you finished your loop, add .repaint() method, so it will update counters. But the main thing is that you need to add/remove these shown/hidden markers from the markerclusterer object automatically on hide/show marker
var markers=[], markerclusterer;
markerclusterer = new MarkerClusterer(map, []);
for(var i=0;i<1000;i++)
{
//create marker
markerclusterer.addMarker(marker, true);
google.maps.event.addListener(marker, 'visible_changed', function(){
if ( marker.getVisible() ) {
markerclusterer.addMarker(marker, true);
} else {
markerclusterer.removeMarker(marker, true);
}
});
}
// then .. in another part .. i do .
for(var j=0;j<200;j++)
{
markers[j].setVisible(false);
}
markerclusterer.repaint();
Hope that will help somebody.
Upvotes: 4