views:

65

answers:

2

I am using the Google Maps JavaScript v3 API.

The maps library takes awhile to load; however, certain functions load before others.

How can I programatically determine the instant the getBounds function is ready for use from the Google Maps JavaScript library?

UPDATE:

Is there some type of event I could create to run once getBounds is declared?

+1  A: 

The function will be ready to use after it's been declared - it may however have dependencies on other things, such as elements in the DOM, which will need to exist in the DOM before the function can run.

If the map takes a while to load, you might consider having a "loading" placeholder to indidcate to users that the map is loading and then hide this when the map is ready.

For a more comprehensive answer, I would need to know more details about exactly what it is you are trying to do.

Russ Cam
+2  A: 

There is no event you can monitor but you can check for existence at intervals..

if (typeof myfunction === 'function')
{
  myFunction();
}

But let me say that what you are proposing smells like rotten fish. ;-)

You are just asking for a world of pain.

I cannot think of a scenario in which I would feel compelled to access a member of a partially loaded library. ESPECIALLY google maps.

Sky Sanders