我使用谷歌地图api v2遇到了一些麻烦。我想要的是能够用鼠标在工具提示上。 以下是我的代码。在firefox工作,但我必须在工具提示上轻轻地移动鼠标,如果我去快速它将隐藏(解决:添加延迟鼠标输出功能,并检查我是否触发工具提示)和最糟糕的部分它在IE中根本没有意义。如果我超过引脚点,我将能够看到工具提示,但我无法用鼠标移动它。
function createHotelSearchMarker(point, number, message) {
var newIcon = new GIcon(G_DEFAULT_ICON);
wIcon.image = imageChart + "chst=d_map_spin&chld=0.5|0|CCCCCC|10|_|" + number + "&ext=.png";
var marker = new GMarker(point, {icon: newIcon, clickable:true, zIndexProcess:importanceOrder});
marker.importance = 1;
/*add listener for mouseover*/
GEvent.addListener(marker, "mouseover", function() {
marker.openExtInfoWindow(
map,
"mapInfoWindow",
"<div id='tooltip'>" + message + "</div>",
{beakOffset: 3}
);
marker.setImage(imageChart + "chst=d_map_spin&chld=0.5|0|FF0000|10|_|" + number + "&ext=.png");
marker.importance = 2;
marker.setLatLng(marker.getLatLng());
/*i added a dom listener for the tooltip*/
if(document.getElementById("tooltip") != null) {
GEvent.addDomListener(document.getElementById("tooltip"), "mouseover", function(){
isFiredByDivListener = 1;
GEvent.trigger(marker,"mouseover");
});
GEvent.addDomListener(document.getElementById("tooltip"), "mouseout", function(){
isFiredByDivListener = 0;
GEvent.trigger(marker,"mouseout");
});
}
});
/*add a listener for mouse out*/
GEvent.addListener(marker, "mouseout", function() {
map.closeExtInfoWindow();
marker.setImage(imageChart + "chst=d_map_spin&chld=0.5|0|CCCCCC|10|_|" + number + "&ext=.png");
marker.importance = 1;
marker.setLatLng(marker.getLatLng());
});
return marker;
}
the marker will be return and
if (marker != null){
map.addOverlay(marker);
}
感谢您的帮助和时间
答案 0 :(得分:0)
在我看来,你已经开始这样做,即你可以递归触发标记鼠标悬停的潜在问题。我建议将两个addDomListener事件侦听器移到标记的事件侦听器之外。
GEvent.addListener(marker, "mouseover", function() {
...
GEvent.addDomListener(document.getElementById("tooltip"), "mouseover", function(){
GEvent.trigger(marker,"mouseover");
});