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
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
Share asked Nov 9, 2012 at 20:50 IbrahimAsadIbrahimAsad 5161 gold badge5 silver badges16 bronze badges1 Answer
Reset to default 4when 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745044346a4608002.html
评论列表(0条)