Marker Clusterer Plus在悬停时更改图标 [英] Marker Clusterer Plus change icon on hover
本文介绍了Marker Clusterer Plus在悬停时更改图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 Marker Clusterer Plus for Google Maps V3?
标记似乎没有公开任何方法来修改它们。我需要做这样的事情(或相当于)。
google.maps.event.addListener(markerCluster,mouseover,函数(集群){
cluster.setIcon(hoverIcon);
});
google.maps.event.addListener(markerCluster,mouseout,function(cluster){
cluster.setIcon(normalIcon);
});
解决方案
有一个对div元素的引用,它表示集群。这个div的第一个孩子是img元素,改变这个图像的src:
google.maps.event.addListener (markerCluster,'mouseover',function(c){
c.clusterIcon_.div_.firstChild.src ='hoverIconPath'});
google.maps.event.addListener(markerCluster,'mouseout',function(c){
c.clusterIcon_.div_.firstChild.src ='normalIconPath'});
How can I dynamically change the Icon used for a specific Cluster in Marker Clusterer Plus for Google Maps V3?
The markers do not seem to expose any methods at all to modify them. I need to do something like this (or equivalent).
google.maps.event.addListener(markerCluster, "mouseover", function (cluster) {
cluster.setIcon(hoverIcon);
});
google.maps.event.addListener(markerCluster, "mouseout", function (cluster) {
cluster.setIcon(normalIcon);
});
解决方案
There is a reference to the div-element that represents the cluster. The first child of this div is the img-element, change the src of this image:
google.maps.event.addListener(markerCluster,'mouseover',function(c){
c.clusterIcon_.div_.firstChild.src='hoverIconPath'});
google.maps.event.addListener(markerCluster,'mouseout',function(c){
c.clusterIcon_.div_.firstChild.src='normalIconPath'});
这篇关于Marker Clusterer Plus在悬停时更改图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文