Franziskus Karsunke Franziskus Karsunke - 7 months ago 16
Javascript Question

Does an event get fired after the Mapview is fully rendered in openlayers 3?

I am rendering about 27000 Markers in different layers on a mapview. Everything works fine on a fast device.

I have a problem on older devices (like the iPad3). When i hide one layer and set another layer to visible = true, it takes several seconds for the change to take affect on the mapview. The mapview is frozen in this time and any user interaction is delayed until the mapview has finished rendering. It would be better for me to show a loading popup and wait until the view has finally finished rendering.

Is there any event which gets fired after the rendering on the mapview has finished?

Answer

I found another question (http://gis.stackexchange.com/questions/10671/register-event-loadend-on-layer?rq=1) with one answer which lead me to the right event:

vectorLayer.on('postcompose', function(event) {
    if (vectorLayer.getVisible()) {
         doSomething();   
    }
});

The method doSomething(); is now called when the corresponding vector layer was completely rendered on the Canvas.