OpenLayers 2 – Is There a Map-Level Event to Signal the Start or End of Drawing?

openlayers-2

In OpenLayers, is there an event which fires when the map starts drawing any layer, and another for when the map has finished drawing all layers?

I wish to display a "waiting" animation while any layer is still drawing.

The help file for LoadingPanel mentions something which sounds promising, but the sample doesn't work and it mentions tiles (I'd like it to work on vector layers too).

I'm looking for the equivalent of dojo.connect(map,"onUpdateEnd"… in the ArcGIS JS API:

Fires after layers that are updating their content have completed.
This event is often used in combination with onUpdateStart to display
a "Map is busy" or "Loading? " message as visual feedback to the
end-user.

(As a workaround, I could count the layers in the map, and monitor the status of each layer using layer.events.register("loadend"... until they have all finished. Are there other options?)

Thanks

Best Answer

A loading panel is available as an add-in and was first mentioned here. You can either use that or hack it to suit your needs; anyway imho it provides good enough functionality.

The linked example does not work so I took the liberty of assembling a working jsfiddle:

http://jsfiddle.net/bxpjT/1/