[google maps API] 關閉所有開啟的 infowindow

  1. var infoWindows = [];  

  1. //add infowindow to array   
  2. infoWindows.push(infowindow);   

再加這個就可以了。

  1. function closeAllInfoWindows() {   
  2.   for (var i=0;i<infoWindows.length;i++) {   
  3.      infoWindows[i].close();   
  4.   }   
  5. }  

出處: Close all info windows google maps API V3?

留言