It seems that drawing of polygons is asynchronous in google maps api v3. Try to click the "Load" button in this example:
http://jsfiddle.net/rmXXF/
the text "DONE" is written much sooner than the grid is drawn! It seems that drawing of rectangle grid is asynchronous. I want the text DONE displayed AFTER the grid is drawn! Is there some event handler for this?
The important part of code is in function action()
:
polygons = draw_all_squares(map); // draw grid here
document.getElementById('status').innerHTML = 'DONE'; // displayed 2 seconds
// before the grid!
Note that map 'idle' event doesn't work for this, because the map is not moving/zooming. You can try here:
http://jsfiddle.net/92Hxj/
Maybe it has something to do not with google maps but with browser rendering? In any case, some event handler for this should be present.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…