egeloen / IvoryGoogleMapBundle

Google Map API v3 integration for your Symfony2 project.
https://github.com/egeloen/ivory-google-map
MIT License
217 stars 152 forks source link

Closing other info windows when opening one #16

Closed wodor closed 12 years ago

wodor commented 12 years ago

You could consider adding an option to map (?) , to allow only one info window to be opened.

this can be done by changing the way event is created instead of


var event_4f07735701880 = google.maps.event.addListener(marker_4f077356f28a6, "click", function(){info_window_4f077356f2a9b.open(tripsmap, marker_4f077356f28a6);});

you could create something like this


var event_4f0772ee84f28 = google.maps.event.addDomListener(marker_4f0772ee84ce0, "click", function() {
            if(openedInfoWindow !== undefined) {
                openedInfoWindow.close();
            }
            info_window_4f0772ee84e10.open(tripsmap, marker_4f0772ee84ce0);
            openedInfoWindow = info_window_4f0772ee84e10;
            }, false);

(this code is not state-of-the-art but works)

the drawback is that there must exist 'openedInfoWindow' somewhere in global javascript scope , this is why I think that this should be option of Map.

and maybe there are cleaner solutions....

egeloen commented 12 years ago

The commit resolves this issue. Give me some feedbacks !

wodor commented 12 years ago

Works like charm.