编程语言
首页 > 编程语言> > javascript-markerclusterer mouseover不起作用

javascript-markerclusterer mouseover不起作用

作者:互联网

我只是看了以下帖子:markerclusterer info windows

我在这篇文章中需要做一件事,markerclusterer的mouseover事件.当鼠标悬停在图标上时,我需要更改图标.

我得到以下代码:

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);

});

群集器工作正常,信息窗口也显示良好.它结合了集群中标记的所有信息窗口.

在mouseover事件中我在做什么错?我什至看不到console.log!

提前致谢

解决方法:

我的解决方案是使用markerclustererplus而不是markerclusterer.
只需替换您的脚本src.
这是example.

标签:mouseover,google-maps-api-3,markerclusterer,javascript
来源: https://codeday.me/bug/20191101/1982806.html