1

I am using OpenLayers version 3 (answers with ver 2 are also OK) and want to measure how long it takes to render the vector layer. So, I have a vector layer with features:

var vectorLayer = new ol.layer.Vector({
    source: vectorSource
});

And my map object:

var map = new ol.Map({
        renderer: 'canvas',
        target: document.getElementById('map'),
        view: new ol.View({
            center: [550000, 6520000],
            resolution: 500,
            minZoom: 1,
            maxZoom: 10,
            zoom: 1,
            resolutions: [500.0, 250.0, 125.0, 62.5, 31.25, 15.625, 7.8125, 3.90625, 1.953125, 0.9765625, 0.48828125],
            projection: projection
        })
    });

I want to measure how long it takes to render all features from the layer. If I do like this

 var start=performance.now();
 map.addLayer(vectorLayer);
 var time=performance.now()-start;
 console.log(time)

then I see time in console much much earlier than points on map. I want to see the time right after all points are rendered. How can I do that?

1

You could listen to the postrender event which is triggered after a frame is rendered.

map.on('postrender', function(){
  console.log('frame rendered');
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.