Closing any open info windows in google maps api v3

后端 未结 6 1430
旧时难觅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:19

    infowindow is local variable and window is not available at time of close()

    var latlng = new google.maps.LatLng(-34.397, 150.644); var infowindow
     = null;
    
     ...
    
     google.maps.event.addListener(marker, 'click', function() {
         if (infowindow) {
             infowindow.close();
         }
         infowindow = new google.maps.InfoWindow();
         ... });
    ...
    

    REF: Close all infowindows in Google Maps API v3

提交回复
热议问题