Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close Infobox when clicking on the map

I'm using the Infobox plugin for Google Maps V3 API (http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html)

Is there anyway too close the infobox when the user clicks outside the infobox like on the map?

like image 297
Nyxynyxx Avatar asked Jul 01 '11 12:07

Nyxynyxx


1 Answers

it's actually way easier if you have your infowindow as a global variable, or at least hold one variable that represents the single infobox you want to add at a convenient place.

edit: just to clarify: it should not be window.myInfoBox for example. With global I mean a single point where you reference your infobox

google.maps.event.addListener(map, 'click', function() {
    if(infowindow){
       infowindow.close();
    }
});

that's all :-)

like image 101
MJB Avatar answered Sep 28 '22 08:09

MJB