If certain conditions are met when an infoWindow is closed, I want to prevent the default close event that is fired. Is it possible to achieve that? I tried a number of things like:
- Stopping event propagation
- returning false from the callback method
- there aren't any methods/properties exposed by the infoWindow either that prevent close.
Please let me know if this is possible.
The InfoWindow doesn't really provide a way to step event propagation. I don't know if it could work for you, but there is an InfoBox Utility Library that does give you a great deal more of control oven its behavior. Specific to your question, the
InfoBoxOptions
api-doc object includes the property:enableEventPropagation
, a boolean, that will allow you to control whether theInfoBox
will: propagate mousedown, click, dblclick, and contextmenu events in the InfoBox (default is false to mimic the behavior of agoogle.maps.InfoWindow
). Set this property to true if the InfoBox is being used as a map label. iPhone note: This property setting has no effect; events are always propagated.The only thing you can do is catch the
closeclick
event which leads you nowhere.I have hacked something together once, for a one-off solution, that might or might not work for you: I have identified a way to get to the x-mark that the user clicks to close, and removed that. The user can't close the infoWindow. At all. You still can, by calling .close().
WARNING! THIS IS A HACK
Now. If you store a reference to the [x] mark, you could even turn it on and off at will.
EDIT:
A demonstration of this hack
You could always listen for the close event and then throw a javascript error to keep it from closing. Ex: