All right then, allow me the Next n00b Question:
How do I load this Google Maps API script with GUnload in it? I have
this Maps recipe from a book and just applied it exactly as it was in
the book (you know, great programmers don't write code but re-use it).
Turns out the recipe is incomplete.
> The block of code defined as initialize() will never get run until and
> unless it is asked for, in your case at the load event time by the
> window.onload setting.
Yes, but when the thread executes the window.onload setting it IS
being asked to execute initialize() - why doesn't it do that?
I have Googled it and found this:
google.load("maps", "2",{"other_params":"sensor=true"});
function initialize() {
var map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
}
google.setOnLoadCallback(initialize);
Is this how it's supposed to happen?
/ Vahagn
On Jan 16, 1:44 pm, Rossko <[email protected]> wrote:
> > When I load the page at the URL previously cited, the execution jumps
> > from the first line ("function initialize()") to straight outside the
> > function (to "window.onload=initialize;"). Then it continues on to the
> > "window.onunload=GUnload;" line at which point it complains that
> > GUnload is undefined.
>
> Yup, that's what supposed to happen. 'function initialize()' just
> defines or demarcates a bunch of code ... to be run later. So,
> execution comes to 'function initialize()' definition and jumps to
> carry on executing after the end of the function definition. The
> block of code defined as initialize() will never get run until and
> unless it is asked for, in your case at the load event time by the
> window.onload setting.
>
> As Andrew says, GUnload fails because GUnload is defined in the Google
> Maps API script which you haven't loaded yet. Doing things in the
> right order is important, load a script before running it.
>
> cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---