簡體   English   中英

markerclusterer鼠標懸停不起作用

[英]markerclusterer mouseover doesn't work

我剛看了下面的帖子: 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);

});

群集工作正常,infowindow也很好。 它結合了集群中標記的所有信息。

我在mouseover事件中做錯了什么? 我甚至沒有看到console.log!

提前致謝

我的解決方案是使用markerclustererplus而不是markerclusterer。 只需替換你的腳本src 這是一個例子

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM