![](/img/trans.png)
[英]Google Maps MarkerClusterer either doesn't work or hides all markers
[英]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.