0
function bindInfoWindow(marker, map, infoWindow, html) {

    //infoWindow.close(); <---- ignore this one

      google.maps.event.addListener(marker, 'click', function() {

        infoWindow.close();

        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }

This is my function with the listener for when a marker is clicked but regardless to what I do the infoWindows will NOT close unless I click them they just stay on the screen when I click them and sometimes I get an error that there is no Close function. Someone help please!

4

1 回答 1

0

InfoWindow close 工作得很好。我怀疑您希望它关闭不同的信息窗口。

在您的示例中,它将关闭信息窗口(如果它已打开)并立即再次打开它,您可能不会看到它。

尝试添加:

google.maps.event.addListener(map, "click", function() {infoWindow.close();});

然后点击地图。请注意,这可能不是您的最终解决方案,只是一种向您展示它确实关闭的技术。

例子

于 2013-02-09T22:54:19.737 回答