Yep, this is something you will want to do for any variable or object you
will want to be accessing outside of the function in which you declare it.

In case you don't understand scope here's a very simplified explanation:

Variables, when declared inside a function, are private and are only usable
within the function in which you declare them or any of that function's
children functions.

For example, if you want to manage markers or other overlays after you have
created them you will need to push them into either a single variable, or
array if it is more than one, that is a public variable in order for you to
do anything with them after you have created them.  If you declare a
variable inside a function, it is only usable within that function with the
exception that it can be passed to a another function that is called within
the original function at the time, but the variable isn't usable anywhere
else within your program.

If you want your variables to be public variables simply declare the
variables that you want to be public outside of any function.

So where you begin your javascript with the <script> tag just add the
variable declarations there.

You can define them later in the function and they will take that variable,
but since you declared them outside of any of your functions they are
publicly available to your entire program.

-- 
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 [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-js-api-v3?hl=en.

Reply via email to