> ok, so finally i managed to get it work, i used a function that
> creates a new marker insted of passing all the data in the cycle:
...
>  thx for this link  http://econym.org.uk/gmap/basic1.htm:) i still
> don`t know why it didnt work when i tried to add:
>
> GEvent.addListener(marker, "click", function() {...

It's because of 'function closure', which isn't an easy idea to grasp.
   http://econym.org.uk/gmap/closure.htm

When you create the listener in-line in your loop, when it executes it
will use the current value of the variables in it. Not the values as
they were when it was created.

By the time something gets clicked and it does execute, those
variables are all as they got left when the loop had finished.

When you put the listener creation into a seperate function, it forces
javascript to take a 'snapshot' of the variables involved for each
listener that gets created, so they're all different.

cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to