Closing any open info windows in google maps api v3

后端 未结 6 1442
旧时难觅i
旧时难觅i 2021-01-31 03:25

As the title states, on a given event (for me this happens to be upon opening a new google.maps.InfoWindow I want to be able to close any other currently open info

6条回答
  •  太阳男子
    2021-01-31 04:05

    The best way to do this I think... is having an object with the infowindows that you have opened

    I have two objects, infos have all the infowindows created and markers contains all markers with they infowindows so I just execute this functions that loop the infowindow object and close all the infowindows

    function CloseInfowindows() {
      for (var mkey in infos) {
        var mobj = markers[mkey];
        mobj.infowindow.close();
      }
    }
    

提交回复
热议问题