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…
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 -
--~--~---------~--~----~------------~-------~--~----~
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