Since google maps v3 allows you to have multiple InfoWindow''s showing at the same time, it would be nice to have a way to programmatically close the window. In my local repository I handled this by adding a Marker.closeBubble() method. I could supply a git patch for the code, but it is summarized below for the changes to mxn.googlev3.core.js: ----- Marker toProprietary() changes ----- if (this.infoBubble){ this.infoWindow = new google.maps.InfoWindow(); this.infoWindow.setContent(this.infoBubble); var infoWindow this.infoWindow; var event_action = "click"; if (this.hover) { event_action = "mouseover"; } google.maps.event.addListener(marker, event_action, function() { infoWindow.open(this.map,marker); }); } ----- Marker, other changes ----- openBubble: function() { this.closeBubble(); if (!this.infoWindow) { this.infoWindow = new google.maps.InfoWindow(); } this.infoWindow.setContent(this.infoBubble); this.infoWindow.open(this.map,this.proprietary_marker); }, closeBubble: function() { if (this.infoWindow) { this.infoWindow.close(); } }, hide: function() { this.closeBubble(); this.proprietary_marker.setOptions({visible:false}); }, -- Robert Stehwien Software Engineer II Universal Mind, Inc. robert.stehwien at universalmind.com This email, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately and permanently delete the original and any copy of any email and any printout thereof. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100607/afa76fdd/attachment.htm>
Thanks Robert, I was looking into this as well. According to Google (http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows), simply reusing the same infoWindow object will have the same effect, and seems more efficient than creating a new instance for each marker unless we''re going to keep more than one open (see quote from docs below). I''m no javascript ninja, unfortunately, so haven''t yet figured out how to do that within the MXN architecture. Basically, we need to create a single infoWindow object, and then reuse that on the marker click event, obviously resetting it''s content. Help / feedback welcome.> If you only want one info window to display at a time (as is the behavior on Google Maps), you need only create one info window, which you can reassign to different locations or markers upon map events (such as user clicks). Unlike behavior in V2 of the Google Maps API, however, a map may now display multiple InfoWindowobjects if you so choose.Lev Tsypin _____________________ Level Online Strategy, LLC 503.342.8044 levelos.com | twitter.com/levelos -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100607/9121e3d5/attachment.htm>
I ran into that issue as well with Google v3. OpenLayers also provides a choice for multiple info bubbles or a single exclusive bubble. The singular bubble seems to me like it would make an easier-to-manage default behavior that prevents cluttering up the map, and stays consistent with Google v2. But I wonder if anyone would prefer multiple info bubbles when available, as we have with the current v3 implementation? -dylan- On Mon, Jun 7, 2010 at 6:00 PM, Lev Tsypin <lev at levelos.com> wrote:> Thanks Robert, I was looking into this as well. According to Google ( > http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows), > simply reusing the same infoWindow object will have the same effect, and > seems more efficient than creating a new instance for each marker unless > we''re going to keep more than one open (see quote from docs below). I''m no > javascript ninja, unfortunately, so haven''t yet figured out how to do that > within the MXN architecture. Basically, we need to create a single > infoWindow object, and then reuse that on the marker click event, obviously > resetting it''s content. Help / feedback welcome. > > If you only want one info window to display at a time (as is the behavior > on Google Maps), you need only create one info window, which you can > reassign to different locations or markers upon map events (such as user > clicks). Unlike behavior in V2 of the Google Maps API, however, a map may > now display multiple InfoWindowobjects if you so choose. > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100607/b09ca619/attachment.htm>
I had considered making one InfoWindow object up at the Mapstraction level and reusing it down in the Marker. More efficient, but less flexible... not that I actually want multiple info windows up in the app I''m currently writing. Either way works for me. On Mon, Jun 7, 2010 at 6:00 PM, Lev Tsypin <lev at levelos.com> wrote:> Thanks Robert, I was looking into this as well. According to Google ( > http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows), > simply reusing the same infoWindow object will have the same effect, and > seems more efficient than creating a new instance for each marker unless > we''re going to keep more than one open (see quote from docs below). I''m no > javascript ninja, unfortunately, so haven''t yet figured out how to do that > within the MXN architecture. Basically, we need to create a single > infoWindow object, and then reuse that on the marker click event, obviously > resetting it''s content. Help / feedback welcome. > > If you only want one info window to display at a time (as is the behavior > on Google Maps), you need only create one info window, which you can > reassign to different locations or markers upon map events (such as user > clicks). Unlike behavior in V2 of the Google Maps API, however, a map may > now display multiple InfoWindowobjects if you so choose. > > > Lev Tsypin > _____________________ > Level Online Strategy, LLC > 503.342.8044 > levelos.com | twitter.com/levelos > > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com > >-- Robert Stehwien Software Engineer II Universal Mind, Inc. robert.stehwien at universalmind.com This email, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately and permanently delete the original and any copy of any email and any printout thereof. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100607/0dbbfebc/attachment.htm>
Good point on the flexibility. To take advantage of it, though, I think we''d need a flag at either the map or marker level indicating to leave the info window''s open. Lev Tsypin _____________________ Level Online Strategy, LLC 503.342.8044 levelos.com | twitter.com/levelos -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100608/edbdf0fb/attachment.htm>
> > Good point on the flexibility. To take advantage of it, though, I think > we''d need a flag at either the map or marker level indicating to leave the > info window''s open. > > >Yes a flag would be great, I even looked for one when I noticed the info window spawning. -- Robert Stehwien Software Engineer II Universal Mind, Inc. robert.stehwien at universalmind.com This email, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately and permanently delete the original and any copy of any email and any printout thereof. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100608/39d0f637/attachment.htm>