Hi Francisco, Thanks for sharing your tips with me. I think it would be better to have the information back to group. Hope you won't mind if I c.c. the group.
I did use some similar way to resolve the problem. Just hope somebody could fix the issue to make binding feature work as expected. I'm not sure if it's a bug or a feature, so I just open a topic instead opening an issue. ;) -- Finjon Kiang On Mon, Sep 6, 2010 at 6:09 PM, Francisco Ramos <[email protected]> wrote: > Hi Kiang > > I came up with something that works for me. Have a look at this > snippet, it might give you an idea: > > function openInfoWindow(map, marker) { > infowin.set("marker", marker); // associate marker to the > infoWindow > infowin.open(map, marker); > } > > function closeInfoWindowMarker (marker) { > // let's check whether the infoWindow is associated to the marker > we are either hiding or removing from the map > if (infowin.get("marker") == marker) { > closeInfoWindow(); > } > } > > function closeInfoWindow() { > infowin.set("marker", null); // remove association > infowin.close(); > } > > // we want to close infoWindow when hiding marker > google.maps.event.addListener(marker, "visible_changed", function () { > if (this.getVisible() == false) { > closeInfoWindowMarker(this); > } > }); > > // also when removing from the map > google.maps.event.addListener(marker, "map_changed", function () { > if (this.get("map") == null) { > closeInfoWindowMarker(this); > } > }); > > As I said this is working for me and it could be a solution for you. > > Fran > > On Jun 8, 1:20 pm, kiang <[email protected]> wrote: >> 1) Create aMarker >> 2) Create aInfoWindow >> 3) addListener toMarker.click to open theInfoWindow >> 4) Click on theMarker. As expected, theInfoWindowopened. >> 5) Remove themarkerfrom the map throughMarker.setMap(null) >> 6) Well,InfoWindowis still opening there ... >> >> I'm not sure if there's another way to bindInfoWindowwith the map >> property ofMarker. I've tried some solutions with no luck ~ >> >> 1)InfoWindow.bindTo('map',Marker) ~~ not work whenMarker.setMap(null) >> 2)Marker.map_changed = function() {InfoWindow.close(); } >> ~~ It's fun that theInfoWindowbe closed. But theMarkerkeep stay >> there whenMarker.setMap(null) >> >> I could remove them withoutbinding. Just want to know if there's any >> way to bind them together. >> >> --- >> kiang -- 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.
