Auto close infowindow when another is open (Google Map developer)

This one is for the developers fan, exactly for Google Map API developers, a simple but necessary option must be available on your Google Map UI, if your Map got multiple markers with infowindow for every marker, so your Map must automaically close the current infowindow when user click on another maker, on this fast post I'm going to learn you an easy method to do it.The idea is to declare a new global variable "currentinfo" and listen to every marker, when an infowindow is open and user click on any one close the previous one which is stored on the declared variable "currentinfo", then affect the current infowindow to the "currentinfo", so the code is like bellow: