Look up "function closure".

http://econym.org.uk/gmap/closure.htm

You need to create the markers in a separate function.

--
Marcelo - http://maps.forum.nu
--


On Nov 26, 8:42 am, john <john.c...@aafa-inc.com> wrote:
> This might be a javascript (on which I am weak) question. Here is
> sample code:
>
> var marker;
> var infoWindow;
>
> marker = new ... // first marker
> infoWindow = new ... // first infoWinfow.
>
>     google.maps.event.addListener(marker, 'click', function() {
>       infoWindow.open(map, marker);
>     });
>
>     markers.push(marker); // I am using marker manager
>
> marker = new ... // second marker
> infoWindow = new ... // second infoWinfow.
>
>     google.maps.event.addListener(marker, 'click', function() {
>       infoWindow.open(map, marker);
>     });
>     markers.push(marker); // I am using marker manager
>
> // and bunch more
>
> Now, no matter which marker I click, it always pop the infoWindow of
> the LAST marker. I know what the problem is. I don't know how to fix
> it. I could define var for each of the markers. But it's actually a
> loop with thousands of markers.
>
> Any suggestion?
>
> Thanks,
>
> John

-- 
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