close active infowindows from external link google maps api v3
I am working on a website with google maps integrated. http://www.ecompanies.nl/pilot/webdesign/breda.html
Infowindows can be opened by clicking on a map marker, or on a header link in the items listed on the right. How can I close the active infowindow before opening a new one (by clicking on a map marker, or on a header link)?
Thanks in开发者_运维问答 advance. Any help is highly appreciated.
You are creating a new infowindow for each marker. The best way to achieve what you want is to create one infowindow and share that between all the markers.
So:
- Put the infowindow creation before the loop.
- When you create the click event listener for the marker in the loop add
infowindow.setContent('content');
before you open the marker.
this will automatically close the infowindow and open it over the new marker
精彩评论