Creating Google Maps Clusters by type

1,062 views
Skip to first unread message

Adrian Latorre Crespo

unread,
Mar 31, 2012, 7:40:16 PM3/31/12
to google-map...@googlegroups.com

I would like to know if it is possible to cluster markers on Google Maps API v3 not only by density or number, but also by type.

For example: I have 20 markers of type A and 50 of type B. Could I have a two different clusters, one grouping all the type A markers and another one with type B markers. Obviously with different icons.

Another possible solution would be a single cluster that its icon would change depending of the number of markers of type.

For example: if we have 20 markers type A and 50 type B, the cluster would be a B-Type image.

Any of this options can be possible? 

Thank you!

Barry Hunter

unread,
Apr 7, 2012, 8:08:35 AM4/7/12
to google-map...@googlegroups.com
I think you can have multiple markerclusters on one map.

So each one clusters a different type of marker.

The only issue, is that the cluster markers may end up overlapping (or
even being exactly on top of each other) - the two clusterers wont be
aware of each other to avoid placing markers on top of each other.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/pi39Z7Eq_yAJ.
> 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.

Sean Mickey

unread,
Apr 8, 2012, 1:47:16 PM4/8/12
to Google Maps JavaScript API v3
Yes, it is possible to work with multiple clusters on one map; I have
used as many as 7 clusters, with a different marker for each, on a
single map. As Barry Hunter describes in his response post, it can
lead to overlapping cluster markers, but it was not a frequent or
large problem on my maps. Each of my marker types have a separate on/
off display, so in scenarios where cluster markers collided, it was
easy for users to turn the different types on and off to clarify the
display.

Your second idea, focused on having the cluster marker change based on
the number of each marker subtype within a cluster, is certainly
possible, but the cluster libraries do not seem to be setup to readily
handle this type of functionality very well. The API is focused on
creating a cluster and adding or removing markers to or from the
cluster. I can't think of any library callbacks or API facilities for
dynamically changing the cluster marker appearance based on the number
of clustered markers by subtype.

I have worked in scenarios where multiple subtypes of a cluster could
have their display turned on/off, which made it necessary to
frequently add or remove marker subsets to or from a cluster. This
worked fine and the cluster performed dynamic cluster updates that
were pretty responsive and resulted in a nice transition as the
subtype displays were turned on and off.

I work primarily with MarkerClustererPlus and I'm currently using
version 2.0.9.

On Mar 31, 7:40 pm, Adrian Latorre Crespo <adri.lato...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages