<sheepishly> [I said] It's a shame there's no infowindowopen event from the marker ...
Just noticed GMarker DOES generate this event (just like GMap2). So, tried out the impl I speculatively proposed yesterday, and it works fine. </sheepishly> On Jan 2, 3:02 pm, David Easley <[email protected]> wrote: > Thanks for the pointer, Andrew. > > > You may be able to add your handlers *after* the openInfoWindow call > > -- but be aware that it can take some time to do everything in order > > to make the infoWindow references in the DOM available. > > Yes, some temp/experimental code (using setTimeout to wait for two > seconds before trying to navigate into the InfoWindow) shows this to > be the case. So, I considered hooking into GMap2's infowindowopen > event (and using map.getInfoWindow() to optimise) but that code would > obviously need to be scoped for the whole map, which feels as > inelegant that theobtrusivejavascript option (and probably more > cumbersome). > > It's a shame there's no infowindowopen event from the marker; that > would permit a reasonably elegant solution, e.g.: > > GEvent.addListener(gMap, "click", function(marker) { > if (marker) { // user clicked a marker > // Clone the template info window HTML. > marker.openInfoWindowHtml($('walker_area_info_window').down > ().cloneNode(true)); > > // When the info info is ready, attach handlers to our > widgets. > var listener = GEvent.addListener(marker, "openInfoWindow", > function(marker) { > GEvent.removeListener(listener); > $('map_canvas').down('input.walker_area_update').observe > ("click", function(ev) { > // Handle user interaction with our widget... > }); > }); > } > }); > > David > > On Jan 2, 2:19 pm, "warden [Andrew Leach - Maps API Guru]" > > <[email protected]> wrote: > > On Jan 2, 1:38 pm, David Easley <[email protected]> wrote: > > > > Can I attach event handlers programmatically, or will I have to resort > > > to havingobtrusiveevent handlers (e.g. onclick="...") hard coded in > > > the HTML that I'm cloning? > > > Event handlers in the HTML should certainly work. > > > It's difficult to tell what's actually going on without a link, but I > > suspect that at the time you attempt to navigate the DOM that > > particular element has not been added to it: that happens only when > > the infoWindow is constructed for display. > > > You may be able to add your handlers *after* the openInfoWindow call > > -- but be aware that it can take some time to do everything in order > > to make the infoWindow references in the DOM available. You can > > optimise that time by doing a map.getInfoWindow() call after > > constructing the map: this forces the infoWindow module to be loaded > > then rather than at the first openInfoWindow. > > > Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
