On Feb 23, 11:27 am, jameslove <[email protected]> wrote:
> But doesn't the Marker manager need the map to be more than just
> defined? I thought I'd tried that and the markermanager complained.

You need to understand how the code you are writing works.  The marker
manager doesn't use the map variable until after it is initialized in
the load function.

You will need your marker manager to be global as it is used by the
labelclick function which is called by an html onclick function and
therefor runs in the global context.

  -- Larry

>
> On Feb 23, 11:16 am, "[email protected]" <[email protected]>
> wrote:
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to