Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Marker Clusterer Plus change icon on hover

How can I dynamically change the Icon used for a specific Cluster in Marker Clusterer Plus for Google Maps V3?

The markers do not seem to expose any methods at all to modify them. I need to do something like this (or equivalent).

google.maps.event.addListener(markerCluster, "mouseover", function (cluster) {
  cluster.setIcon(hoverIcon);
});
google.maps.event.addListener(markerCluster, "mouseout", function (cluster) {
  cluster.setIcon(normalIcon);
});
like image 559
Nicolas Avatar asked Dec 05 '22 08:12

Nicolas


1 Answers

There is a reference to the div-element that represents the cluster. The first child of this div is the img-element, change the src of this image:

    google.maps.event.addListener(markerCluster,'mouseover',function(c){
      c.clusterIcon_.div_.firstChild.src='hoverIconPath'});

    google.maps.event.addListener(markerCluster,'mouseout',function(c){
      c.clusterIcon_.div_.firstChild.src='normalIconPath'});
like image 153
Dr.Molle Avatar answered Dec 17 '22 09:12

Dr.Molle