To check for undefined or null:
if (!marker_pos.infowindow2){
Also, if all you want to do is close an infowindow if it's open, just
call close. It doesn't throw an error if it's already closed.
Chad Killingsworth
On Jul 11, 4:35 pm, 3D-kreativ <[email protected]> wrote:
> Hi,
>
> I was looking for some code to first check if a marker and infowindow
> is on the map and then close them, like this:
>
> if (typeof(marker_pos.infowindow2) === "undefined"){
> //object doesn't exist}
>
> else{
> //the object does exist
> marker_pos.infowindow2.close();
> marker_pos.setMap(null);
>
> }
>
> But I discovered that it doesn't work well. The rest of the script
> with the other markers and infowindows doesn't open when I click on
> them. It feels like the typeof part doesn't work and the script stops?
>
> Could it be done in some other way? Thanks!
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.