One InfoWindow in Google Maps 3

45 views
Skip to first unread message

deanf7

unread,
Feb 2, 2011, 1:25:51 PM2/2/11
to Timemap.js Development
I'm trying to set it so only one info window at a time opens. I
looked in the mxn.googlv3.core.js file and it looks as if it's set to
only allow one window at a time to open, but in my app and the online
example multiple windows can be opened at once. Any thoughts?

Thanks,

Dean

Nick Rabinowitz

unread,
Feb 2, 2011, 2:48:53 PM2/2/11
to farrelld...@gmail.com, Timemap.js Development
Great question. This is a feature of Google Maps v3, which wasn't possible in v2, and I decided to leave it in rather than trying for consistency between map providers. OpenLayers has the same behavior, opening multiple windows. Eventually it would probably be good to have this be a configuration setting in the TimeMap.init() options.

In the meantime, you should be able to do it this way:

tm = TimeMap.init({
    options: {
        openInfoWindow: function() {
            var selectedIndex = tm.getSelected();
            if (selectedIndex >= 0) {
                tm.getItems()[selectedIndex].closeInfoWindow();
            }
            TimeMapItem.openInfoWindowBasic.call(this);
        }
    },
    // etc
});

This sets a custom openInfoWindow function for your items that tries to close any open windows before opening the new one. Seems to work in my test.

Let me know if that does it! I'll try to include this as a configuration option in the next release.

-Nick


--
You received this message because you are subscribed to the Google Groups "Timemap.js Development" group.
To post to this group, send email to timemap-d...@googlegroups.com.
To unsubscribe from this group, send email to timemap-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/timemap-development?hl=en.


Dean Farrell

unread,
Feb 2, 2011, 3:54:37 PM2/2/11
to Nick Rabinowitz, Timemap.js Development
Thanks Nick,

It worked perfectly.

Thanks for taking the time to answer my question,

Dean

deanf7

unread,
Mar 9, 2011, 10:52:16 AM3/9/11
to Timemap.js Development
Nick,

Upon further testing it works most of the time, but it seems some
selected Indices are actually less than 0. I've discerned no real
pattern as to when it leaves multiple windows open other than if you
open one window and then open another leaving both open, and then open
a third window the second one will shut correctly leaving the first
and third windows open. This continues on if you open further windows
the first window will always stay open while subsequent windows close.

Thanks,

Dean

On Feb 2, 2:48 pm, Nick Rabinowitz <n...@nickrabinowitz.com> wrote:
> Great question. This is a feature of Google Maps v3, which wasn't possible
> in v2, and I decided to leave it in rather than trying for consistency
> between map providers. OpenLayers has the same behavior, opening multiple
> windows. Eventually it would probably be good to have this be a
> configuration setting in the TimeMap.init() options.
>
> In the meantime, you should be able to do it this way:
>
> tm = TimeMap.init({
>     options: {
>         openInfoWindow: function() {
>             var selectedIndex = tm.getSelected();
>             if (selectedIndex >= 0) {
>                 tm.getItems()[selectedIndex].closeInfoWindow();
>             }
>             TimeMapItem.openInfoWindowBasic.call(this);
>         }
>     },
>     // etc
>
> });
>
> This sets a custom openInfoWindow function for your items that tries to
> close any open windows before opening the new one. Seems to work in my test.
>
> Let me know if that does it! I'll try to include this as a configuration
> option in the next release.
>
> -Nick
>
> On Wed, Feb 2, 2011 at 10:25 AM, deanf7 <farrelldlfarr...@gmail.com> wrote:
> > I'm trying to set it so only one info window at a time opens.  I
> > looked in the mxn.googlv3.core.js file and it looks as if it's set to
> > only allow one window at a time to open, but in my app and the online
> > example multiple windows can be opened at once.  Any thoughts?
>
> > Thanks,
>
> > Dean
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Timemap.js Development" group.
> > To post to this group, send email to timemap-d...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > timemap-develop...@googlegroups.com<timemap-development%2Bunsu...@googlegroups.com>
> > .

Nick Rabinowitz

unread,
Mar 9, 2011, 2:17:24 PM3/9/11
to farrelld...@gmail.com, Timemap.js Development
Thanks for the feedback - I'll need to play with this a bit. The issue is that it's quite hard, with Mapstraction, to reliably know when an info window is open; and most map providers don't offer a close-all-windows function. Right now the openInfoWindow function sets the index of the selected item in the TimeMap opts object, and then unsets it when closeInfoWindow is called (and/or when it gets a closeBubble event from the placemark, though I don't know how well this works with map providers other than Google). It sounds like in your case, the initial selected index isn't always being set properly. I'm hoping to refine the mechanism for this a bit and add some unit tests in an upcoming release, but haven't had the chance yet.

Sorry not to be more help -

-Nick

To unsubscribe from this group, send email to timemap-develop...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages