On Mar 29, 6:52 am, Mitch <[email protected]> wrote: > I'm stuck on something and was wondering if anyone here might know the > answer. > > Example to help explain my problem (look at the > source):http://locatd.org/example.html > > When you right click an information window comes up with a button on > it. What this button does is specified by it's onclick attribute. > > Functions inside the initialize method will not execute if called > here, for example function1 in my code. (Although will execute if > called directly in the code.) > > Functions outside of the initialize method work (such as function2) > but if I do it this way I am unable to manipulate the map (such as how > I am trying to in function3). > > Does anyone know how I can have a method called by a button that will > allow me to manipulate the map?
You are struggling with variable/function scope. See this explanation in Mike Williams' (v2) tutorial: Javascript Concepts - Part 1 Scope http://econym.org.uk/gmap/scope.htm Onclick events run in the global context/scope. function1 is local to your initialize function. -- Larry -- 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.
