[OpenLayers-Users] Measure layer rendering time

Olga Troškina olga.troskina at gmail.com
Sun Mar 1 09:34:43 PST 2015


Here is my code to add vector layer in Openlayers 2.11, using which I want
to measure vector layer rendering time.
I tried "loadend" event, but if I have many features I can see with my eyes
that this is not that time I want. I want to stop measuring when all
features are fully rendered and appear on the map.
Is there any event to register end of rendering of features on the map.
My full code:
var start = performance.now();
    proj4.defs("EPSG:3301", "+proj=lcc +lat_1=59.33333333333334 +lat_2=58
+lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
    var projection = new OpenLayers.Projection('EPSG:3301');
    var renderer =
OpenLayers.Util.getParameters(window.location.href).renderer;
    renderer = (renderer) ? [renderer] :
OpenLayers.Layer.Vector.prototype.renderers;
    var map = new OpenLayers.Map('map',
            {
                projection: projection,
                maxResolution: "auto",
                maxExtent: new OpenLayers.Bounds(300000, 6.3e+06, 800000,
6.7e+06),
                center: [550000, 6520000]
            });
    var wfs = new OpenLayers.Layer.Vector("States", {
        isBaseLayer: true,
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
            url: '
http://loom-gis.geo.ut.ee:8080/geoserver/ermas/ows?service=WFS',
            featureType: "testdata_geopnt",
            featureNS: 'http://loom-gis.geo.ut.ee:8080/geoserver/ermas',
            srsName: "EPSG:3301",
            geometryName: "geometry",
            maxFeatures: 3000
        })
    });
    wfs.events.register("loadend", wfs, function () {
        var time = performance.now() - start;
        console.log(time);
    });
    map.addLayer(wfs);
    map.zoomToMaxExtent();
    map.zoomTo(0);
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20150301/83e55588/attachment.html>


More information about the Users mailing list