views:

411

answers:

1

My site uses the Google Maps API. In situations where the connection to Google is slow and the map can't be rendered in a reasonable time, I'd like a Javascript callback method to be called such that I can display a useful message to the user rather than have a 'loading...' message constantly displayed.

Is this achievable?

+2  A: 

Maybe you could have a sleep function that would check if the page has loaded yet, and after a certain time you take some sort of action.

See this posting for a situation similar to yours

setTimeout might be useful too.

so, you would have:

setTimeout((function() 
           { /* test if the page is loaded, 
                if so, call another function 
                or set a flag to get out*/
           }),2000); //set for 2 seconds
cbrulak