You missed the point of Andrew's comment. Instead of duplicating all the
code that sets up the map1 variable and the map items in both your
initialize() and centerAndZoomOnBounds() functions, go back to when you had
that code only once, in the initialize() function. Take out the duplicate
code in centerAndZoomOnBounds().

Then make one simple change to that code in initialize(): Take the "var" out
of the "var map1 = ..." statement, and instead add a new "var map1;"
statement at the global level (e.g. where you have your "var geocoder").

Now, the code in centerAndZoomOnBounds() that uses map1 will use your
*global* map1 variable that the initialize() function has set up.

You will find that this gives you much cleaner results when you change
countries, because it doesn't have to reload the entire map each time as
your new code does.

-Mike

On Fri, Mar 19, 2010 at 3:00 AM, vincent <[email protected]> wrote:

> Hello
> thanks for the feedback
> i think i understood now this var.
> http://www.weltmeer.ch/divelog/
> and it works!
> I will now have to get it with Global Variable but at least it works
> and looks nice
>
> have a nice day
> vincent
>
>
> On Mar 19, 12:33 am, Andrew Leach <[email protected]>
> wrote:
> > On Mar 18, 11:11 pm, vincent <[email protected]> wrote:
> >
> > > Hello
> > > i have got a errorhttp://www.weltmeer.ch/divelog/
> > > when selecting in the top,right Corner a country
> > > i find the error with the error console from firefox
> >
> > > but i my opinion a couple of line below it is defined
> > > so i am a little bit confused
> >
> > It's true. map1 is not defined when the select element triggers its
> > event. map1 is only defined while function initialize() is executing.
> >
> > Events on HTML elements always run in global scope, and require
> > variables to be available. Define map1 as a global variable and assign
> > it in function initialize(). Don't define it there. Hint: the keyword
> > "var" defines a variable.
>
> --
> 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]<google-maps-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api?hl=en.
>
>

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