Search code examples
javascriptgoogle-mapsgoogle-maps-api-3markerclusterer

Google Maps Api Marker Cluster Activate?


I'm using Google Maps to set some markers. I have things setup so that when an item in a list is hovered on the marker will highlight.

This is done easy enough by keep a hash of the markers. So that when I hover over an item it just updates the icon in the marker.

this.markers[hoverItem.id].setIcon('/img/map/active-marker.png');

This works just fine. However I'm also using the marker-clusterer-plus plugin with Google Maps. The problem I'm having is to highlight the cluster icon if the marker is inside.

I can't find away to access the cluster object of the marker. Is there anyway to access or set it somehow?


Solution

  • Looking at the code...:

    ...you'd probably need to call MarkerClusterer.getClusters to get all the clusters.

    Then loop through them, perhaps then calling Cluster.getMarkers and checking if your marker is in each cluster's array of markers.

    Cluster.isMarkerInClusterBounds and Cluster.isMarkerAlreadyAdded_ might also be useful.