This is a very common issue and Daniel wrote an excellent description
of how to address this:
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f40390e4a6ba89e9/25a246d92f93e9ea#25a246d92f93e9ea

Chad Killingsworth

On May 24, 2:34 am, Heitor <hbgou...@gmail.com> wrote:
> Hi,
>
> I am new to using google maps, and I am having trouble creating a map
> with multiple markers each with their own unique info window. Since I
> have lots of markers to add and may have more in the future, I decide
> to create an array to put all the markers and their info windows on
> the map. This raises the problem of closure, which is where I am
> stuck. To deal with the problem, I created a function to encapsulate
> the marker and the info window creation commands. However, I cannot
> get the script to loop through the array to extract the data needed to
> create the markers and info windows once I've added the function.
>
> My map can be found at:http://www.advancementplus.org/psc2.html
>
> The syntax I am using to call the function (not shown on the website
> since otherwise the map will not load) is as follows:
>
> for (var i = 0; i < places.length; i += 1) {
> addMarker(places[i], i);
>
> }
>
> Many thanks for your help.
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-maps-js-api-v3+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-maps-js-api-v3?hl=en.

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