Google Maps API v3 infowindow close event/callback?

后端 未结 4 1006
攒了一身酷
攒了一身酷 2020-12-13 12:14

I like to keep track of any and all infowindows that are open on my Google Maps interface (I store their names in an array), but I can\'t figure out how to remove them from

4条回答
  •  眼角桃花
    2020-12-13 12:34

    there's an event for infowindows call closeclick that can help you

    var currentMark;
    var infoWindow = new google.maps.InfoWindow({
                content: 'im an info windows'
            });
    google.maps.event.addListener(marker, 'click', function () {
              infoWindow.open(map, this);
              currentMark = this;
    
    });
    google.maps.event.addListener(infoWindow,'closeclick',function(){
       currentMark.setMap(null); //removes the marker
       // then, remove the infowindows name from the array
    });
    

提交回复
热议问题