> But I insist (curiosity killed the cat...);
>
> How to reload a map after it has been overwritten by something else?
> This must simply be a case of reinitializing Google's code, but how?
OK, here's how I've done it (simplified):
1. In the head section of the page there is a script with a function
that initializes the map; let's call it initialize().
2. Within the initialize() function there is a call to a function that
actually creates the map:
createMap(map_canvas,mapOpts,arguments.callee);
Notice the third param: arguments.callee
This is referring to the initialize() function.
3. Within the createMap() function, that param is (arbitrarily) named
caller, and is used as follows:
// Store the original load function for reload
loadFcn = (caller) ? caller : function(){location.reload()};
4. Make sure that loadFcn() is visible outside the initialize() and
createMap() functions; one way would be to put
"var loadFcn;" in the page script.
5. Now, anytime there's a reason to reload the map, just call loadFcn
();
Sorry if this seems complex. I've simplified it from a completely
object-oriented approach that avoids global variables.
The main point is that you can pass a function's argument.callee to a
variable and then use that variable to re-invoke the original
function, including its original parameters. By doing this with the
function that initializes the map, the resulting "reload" is faster
than using the browser's reload/refresh command, because it's not re-
summoning the entire page from the server.
HTH
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---