On Feb 23, 11:13 am, jameslove <[email protected]> wrote: > It doesn't work if I pull out the function since the function relies > on the map being defined which is in the load function. Can I define > the map prior to the load?
Yes. You can define the map _variable_ in the global context var map; then inside the load function, initialize it map = ... -- Larry > > On Feb 23, 9:24 am, Andrew Leach <[email protected]> > wrote: > > > > > On Feb 23, 5:06 pm, jameslove <[email protected]> wrote: > > > > I get a "labelclick is not defined" error on this map. I thought the > > > issue might be that I need to move the function labelclick out of the > > > onload, but then I get undefines on "map". > > > Yes: if you want to run a function from something like a click event, > > the function must be in global scope. If it's inside another function, > > then it only exists while that containing function is being executed. > > > There's usually no reason for nested functions; generally functions > > can usefully *all* be global. Of course, there are always specific > > instances where nesting functions is the right thing to do, but they > > are rare. > > > labelclick needs to be global. If you explicitly define as global the > > variables you want to be available to each function (like map and the > > MarkerManager variables) it might work. > > > Andrew- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
