On Mar 16, 4:30 pm, Mothermugger <ivan.of.the.oza...@gmail.com> wrote:
>
> so the infowindows content is attached to the pin being created at that
> moment in the loop

Actually, the infoWindow's content is BROUGHT FROM the pin being
created. "this" refers to the marker, and "this.html" is its html
property. When the marker's click event is fired, you get that
property's value from the marker, and set the content of the
infoWindow.

With this code,
            google.maps.event.addListener(marker, "click", function ()
{
              window.open(sites[3],"_self");
            });
when the marker's click event is fired, you open the window with
whatever sites[3] contains at that time. It's not related to the
marker.

> I was looking for something like that for the simple function of a URL link.

Do something similar. Your html property is already a custom property,
so simply add another one -- although it's probably best to use
something which Google won't use later on --
            var marker = new google.maps.Marker({
                html:   sites[0],
                myURL: sites[3],
                ...
            });

and then use it where you need it:
            google.maps.event.addListener(marker, "click", function ()
{
                window.open(this.myURL,"_self");
            });
which finds the myURL property of the marker, and then uses that to
open the window.

Actually I'm rather surprised it's that easy to add and use custom
properties. Using the markerOptions object to do so is undocumented,
it appears, and it might break.

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to