MarkerClusterer - removing individual clusters

3,742 views
Skip to first unread message

Barry Hathaway

unread,
Jun 24, 2011, 10:01:39 AM6/24/11
to Google Maps JavaScript API v3
Does anyone know how to remove or hide individual clusters when using
MarkerClusterer? I have "setCalculator" to a function that counts the
markers in my clusters based upon criteria in the marker. As such the
counts can go to zero. In that case I would like hide the cluster.
Thanks in advance.

Javo Rosales

unread,
Jun 24, 2011, 4:29:06 PM6/24/11
to google-map...@googlegroups.com
When you zoom the map, dont you get any marker individualy?, so i guess when you use markerclustered you put all of them into a array dont you? then you must addd

GEvent.addEvent(marker,"click",function(point){

   map.removeOverlay(marker);
   for (int i =0; i<array.size(); i++){
        if (array[i].latlng() = point) { array[i].remove()}


   }
});


Or somthing like that, also you must declare your "Array" as a global variable iguess >.<
2011/6/24 Barry Hathaway <barry.r....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Barry Hathaway

unread,
Jun 29, 2011, 8:10:26 PM6/29/11
to Google Maps JavaScript API v3
I answered my own question. I just updated the updateIcon method to
hide the clusterIcon when the getCalculator method returns a certain
text string.

On Jun 24, 10:01 am, Barry Hathaway <barry.r.hatha...@gmail.com>
wrote:

Daejeon

unread,
Jul 25, 2011, 4:49:34 AM7/25/11
to google-map...@googlegroups.com
If there is no getCalculator? Is there any method to hide the icon? Thanks for the answer 

Gary Little

unread,
Aug 4, 2011, 7:05:02 PM8/4/11
to Google Maps JavaScript API v3
There is no documented way to programmatically hide a cluster other
than by using the minimumClusterSize property.

Barry could probably get the desired effect by using
MarkerClustererPlus (an enhanced version of MarkerClusterer), however.
What you would do is hide markers that don't meet your criteria and
show those that do. For this to work, you must set the ignoreHidden
property to true when creating the marker clusterer. You must also
call the marker clusterer's repaint() method after changing the hide/
show status of any marker (or once after changing the status of all
the markers in a batch). You don't have to provide a custom calculator
because the standard calculator will include only those markers that
satisfy your criteria (i.e., the visible markers). You will never see
a cluster icon with a "0" label again.

I use this technique for my interactive real estate map and it works
great. It is one of the main reasons I created MarkerClustererPlus in
the first place.

See http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/
Reply all
Reply to author
Forward
0 new messages