OpenLayers: How to detect the map view is completely loaded?

zeodtr picture zeodtr · Dec 16, 2015 · Viewed 14.3k times · Source

I'm implementing map exporting functionality using OpenLayers 3.

But there is one problem: one cannot determine whether the map view is completely loaded or a few tiles is missing yet.

It seems there is no such API or event. The close one is tileloadstart - tileloadend pair. But OpenLayers loads tiles asynchronously, and before the tile is actually loading the tileloadstart is not fired - that is, a tile that is queued in the tile queue does not fire the event before actually loading.

Hot can I detect the map view is completely loaded?

Answer

BartBiczBoży picture BartBiczBoży · Apr 14, 2016

postrender event seems to do the trick, like this:

map.once('postrender', function(event) {
    doyourmagic();
});

Works at least from OpenLayers 3.8.2. There is fine answer there about the subject.