Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change icon of markercluster depending on marker type inside the cluster

I have a map with markers of at this time two different types: photos and blog posts. I would like to use a clustering system, preferably MarkerClusterer. Is there a way to change the marker icon dynamically, or in other words, depending on what kinds of marker (photos or posts) are inside the cluster? For example, if the cluster only consists of photos, I would like to display some sort of camera icon, if there are only posts inside the cluster, I might want to display a letter. And if all types of markers are inside the cluster, I would like to use some sort of combined icon.

Can I somehow insert this check where I assign the URL of the icon in MarkerStyleOptions?

A bonus would be to also display the amount of markers of each type in the icon, i.e. two numbers.

Does anyone see a way to do this without having to change the source code?

I guess the simplest option is to keep each marker type in a seperate clusters ...

like image 754
Dreamingof8a Avatar asked Jun 26 '12 11:06

Dreamingof8a


1 Answers

You must create a different array of marker for each group that you created. And try to create a MarkerCluster for each one.

like image 200
Reinaldo Braz Avatar answered Oct 21 '22 05:10

Reinaldo Braz