根据MarkerClusterPlus 文档,不会为 MarkerCluster 类触发mouseover
and事件。我什至尝试在事件中填充它,因为我注意到你需要等待这个,然后再对集群进行任何其他操作,但没有运气。mouseout
clusteringend
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(arrLocLatLng[0], arrLocLatLng[1]),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var arrMarkers = [
new google.maps.Marker({
position: new google.maps.LatLng(myLat1, myLng1)
}),
new google.maps.Marker({
position: new google.maps.LatLng(myLat2, myLng2)
})
];
var mcOptions = {gridSize: 50, maxZoom: 15};
var mc = new MarkerClusterer(map, arrMarkers, mcOptions);
// need to wait for clusteringend, otherwise clusters may not be in DOM
google.maps.event.addListener(mc, 'clusteringend', function () {
var arrClusters = mc.getClusters(); // will just be one
// THIS IS NOT FIRING
// Event name: mouseout
// Event args: c:Cluster
// Event Desc: This event is fired when the mouse moves out of a cluster marker.
google.maps.event.addListener(arrClusters[0], 'mouseover', function ()
{
alert('mouseover event triggered on this particular cluster);
});
// ALSO NOT FIRING
// Event name: mouseover
// Event args: c:Cluster
// Event Desc: This event is fired when the mouse moves over a cluster marker.
google.maps.event.addListener(arrClusters[0], 'mouseout', function ()
{
alert('mouseout event triggered on this particular cluster);
});
});