I tried it in IE and it works fine if you remove the "var" declaration
when declaring the map variable inside the initialize function.

I agree with you very much about declaring the variables up front.

Being a newb to google maps api I just didn't notice that the variable
was local, as I was too busy looking at so many other new and exciting
things :).

Thanks very much for your help Larry.

you the man!

Perhaps you have the time to look at the other problem that I posted
here yesterday?
http://groups.google.ca/group/Google-Maps-API/browse_thread/thread/a99493c392b2818e/d02b6115298e72fc?hl=en#d02b6115298e72fc

Thanks again dude.


Ken


On Oct 7, 9:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Oct 7, 7:29 am, kendawson <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > THNKS LARRY!!
>
> > You da Man!
>
> > “Global Variable” Gotcha.
>
> > For anyone else who is trying to deal with this perhaps it should be
> > clear that you can declare the map variable inside the “initialize()”
> > function if you want, but by using the “var” statement inside that
> > function, you are declaring that variable as local to that function.
> > So..
>
> > the “map” VARIABLE AS A (LOCAL) VARIABLE looks like this…
> > function initialize(){
>
> > if (GBrowserIsCompatible()){
>
> > var map = new GMap2(document.getElementById("MapCont"));
>
> > and the “map” VARIABLE AS A (GLOBAL) VARIABLE looks like this…
>
> if you want it to work in IE, you will probably need a (and it is good
> practice to declare _all_ your variables)
> var map;
> outside of any function scope (as I said above...)
>
>
>
> > function initialize(){
>
> > if (GBrowserIsCompatible()){
>
> > map = new GMap2(document.getElementById("MapCont"));
>
> > On Oct 7, 8:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Oct 7, 6:30 am, kendawson <[EMAIL PROTECTED]> wrote:
>
> > > > I ried this and it says "map is undefined" is there another example
> > > > where they only have one link set up and it is not created dynamicaly
> > > > in an array. So that we can see how this works.
>
> > > map needs to be a global variable (as both igloo and I specifically
> > > stated).
>
> > > define:
> > > var map;
> > > outside of any function context.
> > > (a search of this group for "global variables" should yield lots of
> > > examples, Mike Williams has a discussion of variable scope on his
> > > tutorial)
> > >   -- Larry
>
> > > > Major newbs here. need simple examples.
>
> > > > Thanks
>
> > > > On Oct 7, 5:45 am, igloo <[EMAIL PROTECTED]> wrote:
>
> > > > >  <a href="javascript:map.setCenter(new GLatLng(newLat, newLng))">...</
> > > > > a>
>
> > > > > provided that map, newLat, newLng are global- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- 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