Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove an InfoWindow when the Marker is removed?

I have a Google Maps div and list of check boxes that I use to filter markers on the map.

But if I click on a marker, open an InfoWindow, and then click on a check box to remove the markers of that type, the InfoWindow is not removed from the map.

After I remove the markers, I call this code but the InfoWindow stays:

try {
    if( infowindow ) {
          infowindow.close();
    }
}
catch(err) { }
like image 723
1110 Avatar asked Apr 28 '12 11:04

1110


1 Answers

function closeInfoWindow() {
        if (infoWindow !== null) {
            google.maps.event.clearInstanceListeners(infoWindow);  // just in case handlers continue to stick around
            infoWindow.close();
            infoWindow = null;
        }
    }
like image 77
Baz1nga Avatar answered Sep 27 '22 23:09

Baz1nga