On Sep 8, 9:26 am, serogen <[email protected]> wrote: > many thanks for the fast response. now i did it similar to your > solution and - i don't know why - it works!!! > could you please explain - the only difference is the trigger call is > moved to a global function and the parameters went into function > variables.
When you use a helper function like this, you are using local variables (elm and index, here) and producing a function closure -- this effectively binds the different instances of the variables together, and because they are local variables it keeps each set of variables separate with each call of the function. Not doing that means that the API simply asks for myMarker[divider], so it will end up with whatever value it has at the end of the loop. > i also can't understand the analogy to pitfall number 3 on > mikes marker page: in his example he overwrites the first marker -> > the result would be that only the second marker has an infowindow > popup but it wouldn't cause an error like my first try?! No: it means that each marker opens an infoWindow on whatever is called "marker" at the time of the click. Your situation isn't *exactly* the same, but it is similar: you were using whatever value "divider" held at the end of the loop. It's worth pointing out again that after four hours asking for a link, it took under half an hour to determine the cause of the problem and devise and document a solution. Andrew --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
