> Ok, where am I supposed to declare rOverlay then (and allRoutes it
> seems)?  If I add it at the top of the function, I get the same result
> (undefined).

OK, that IS a step forward.  You don't want to use a single global
value for different listeners, and now you're not.

The next step is to get 'function closure' on the variable used in the
listener.
   http://econym.org.uk/gmap/closure.htm
Have a look at how closure is obtained in this example
   http://econym.org.uk/gmap/basic1.htm
There are two levels of functions.  You need to create a new function
to set up the route and add the listener, which you would call from
toggleRoutes() passing the current value of rOverlay.   The listener
will then get closure on that value, like a snapshot.

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