Open and Close InfoWindow onclick

后端 未结 3 583
失恋的感觉
失恋的感觉 2021-01-26 11:00

Can anyone help me code inside my eventListener so that an infowindow will do the following: open if it\'s currently closed, and close if it\'s currently open.

I\'ve

3条回答
  •  悲&欢浪女
    2021-01-26 12:00

    You can use something like this:

        infoWindowClosed = true;
    
        google.maps.event.addListener(marker, 'click', function() {
            if (infoWindowClosed) {
                infowindow.open(map, marker);
                infoWindowClosed = false;
            } else {
                infowindow.close(map, marker)
                infoWindowClosed = true;
            }
        })
    

提交回复
热议问题