Google.load Never Calls Callback
I am trying to use the Google Earth plug-in, and have found that it's rather particular about how it is called: if called outside the main flow of the Javascript execution (via set
Solution 1:
This is a timing problem.
google.setOnLoadCallback()
lets you specify a function that is called when the page loads.
When you use setTimeout()
like that, it is calling setOnLoadCallback()
after the page has already loaded, so it never calls your function.
Instead of using google.setOnLoadCallback()
you could do this:
functionloadTheMap() {
google.load("earth", "1.x", {"callback" : init});
console.log('Callback is set');
}
setTimeout(loadTheMap, 200);
I'm a little confused though, because the Google docs say that dynamic loading is not supported for Earth, but I've seen it done in the api samples, and it works for me (in Chrome).
Post a Comment for "Google.load Never Calls Callback"