Google Maps API v3: Close infowindow when DOM element is clicked?

It looks like you're creating a new InfoWindow for each marker Quoting from the Google Maps API Docs : If you only want one info window to display at a time (as is the behavior on Google Maps), you need only create one info window, which you can reassign to different locations or markers upon map events (such as user clicks) Therefore, you may simply want to create one InfoWindow object just after you initialize your map, and then handle the click event handler as follows: google.maps.event. AddListener(curMarker, 'click', function() { infowindow. SetContent(contentString); infowindow.

Open(map, curMarker); }) Then the InfoWindow should automatically close when you click on a new marker without having to call the close() method.

It looks like you're creating a new InfoWindow for each marker. Quoting from the Google Maps API Docs: If you only want one info window to display at a time (as is the behavior on Google Maps), you need only create one info window, which you can reassign to different locations or markers upon map events (such as user clicks). Therefore, you may simply want to create one InfoWindow object just after you initialize your map, and then handle the click event handler as follows: google.maps.event.

AddListener(curMarker, 'click', function() { infowindow. SetContent(contentString); infowindow. Open(map, curMarker); }); Then the InfoWindow should automatically close when you click on a new marker without having to call the close() method.

Great tip! Works perfectly! Thanks Daniel for your help!.

– Landitus Aug 8 '10 at 0:34 Thanks for the info! – Martin Nov 10 '10 at 13:41 I work with the Google Maps API about once a year, and every year I forget that this is the way to handle displaying just one InfoWindow. Thanks!

:) – Mike Branski Nov 4 at 2:20.

Var chicago = new google.maps. CurMarker = new google.maps. Var map = new google.maps.

PointToMoveTo = new google.maps. CurMarker = new google.maps. Var contentString = ''+$el.

Var infowindow = new google.maps. Size: new google.maps.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions