views:

18

answers:

1

Hi!

Is there a way to check first if a infoWindow is set and on the map before use

marker.infowindow.close();

if this isn't set and not on the map, the script don't work? I was thinking of an if statement to check before close?

Thanks!

A: 

You can use the typeof function in Javascript.

if (typeof(marker.infowindow) === "undefined"){
//object doesn't exist
}
else{
//the object does exist
marker.infowindow.close();
}
Nick Canzoneri