简体   繁体   English

markerclusterer鼠标悬停不起作用

[英]markerclusterer mouseover doesn't work

I just looked at the following post: markerclusterer info windows 我刚看了下面的帖子: markerclusterer info windows

There's a thing I need in this post, the mouseover event for the markerclusterer. 在这篇文章中我需要一个东西,即markerclusterer的mouseover事件。 I need to change the icon when the mouse is hovered over the icon. 当鼠标悬停在图标上时,我需要更改图标。

I got the following code: 我得到以下代码:

var clusterOptions = {
    zoomOnClick: false,
    styles: [{
        url: 'images/template/cluster.png',
        height: 68, 
        width: 57,
        textColor: '#FFF'
    }]
}
var markerClusterer = new MarkerClusterer(map, markers, clusterOptions);

google.maps.event.addListener(markerClusterer, "mouseover", function(cluster) {
    console.log('test');
});

// Listen for a cluster to be clicked
google.maps.event.addListener(markerClusterer, 'clusterclick', function(cluster) {

    var markers = cluster.getMarkers();
    var content = '';
    $.each(markers, function () {
        content += this.get('content');
    });

    // Convert lat/long from cluster object to a usable MVCObject
    var info = new google.maps.MVCObject;
    info.set('position', cluster.center_);

    var infowindow = new google.maps.InfoWindow();
    infowindow.close();
    infowindow.setContent(content);
    infowindow.open(map, info);

});

The clusterer works fine and also the infowindow shows up nice. 群集工作正常,infowindow也很好。 It combines all the infowindows from the markers in the cluster. 它结合了集群中标记的所有信息。

What am I doing wrong in the mouseover event? 我在mouseover事件中做错了什么? I don't even see the console.log! 我甚至没有看到console.log!

Thanks in advance 提前致谢

My solution was using markerclustererplus rather than markerclusterer. 我的解决方案是使用markerclustererplus而不是markerclusterer。 Just replace your script src . 只需替换你的脚本src Here is an example . 这是一个例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM