我需要在将光标移动到标记上时显示标记的位置。当我移动标记时,它显示位置。当我离开时,信息窗口不会消失。这令人困惑。我的代码可能有问题。代码是:
function moveInfoWindow(marker, message) {
var moveWindow = new google.maps.InfoWindow({
content: message
});
google.maps.event.addListener(marker, 'mouseover', function() {
moveWindow.open(map, marker);
});
google.maps.event.addListener(marker, 'mouseout', function() {
moveWindow.close();
});
}
结果如下:
尝试更改您的代码,如下所示:
google.maps.event.addListener(marker, 'mouseout', (function(infowindow){
return function() {
infowindow.close();
};