-1

I have the following function that opens my info window for the marker, I am struggling to understand how I can close the active / opened info window before opening another, so that only one info window is active at a time?

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

    info_window.setContent(this.html)
    info_window.open(self.map, this)
    document.querySelector("#js-reset-zoom").classList.remove('active')

})

this.map_markers.push( map_marker )
ekad
  • 14,436
  • 26
  • 44
  • 46
lky
  • 1,081
  • 3
  • 15
  • 31

1 Answers1

0

See the answer on this other question. Close all infowindows in Google Maps API v3

google.maps.event.addListener(map_marker, 'click', function () {
if (info_window) {
    info_window.close();
}
info_window.setContent(this.html)
info_window.open(self.map, this)
document.querySelector("#js-reset-zoom").classList.remove('active')

})

this.map_markers.push( map_marker )

  • I don't know what the rest of your code looks like so you may want to restructure it like the other questions so you are only using one infoWindow so only one is open at a time. – Dan Sponseller Jan 18 '19 at 16:53