2

It appears that features on an ol.layer.Vector are not painted or drawn during panning animations or mouse-drag events (in OpenLayers v.3.1.1) Does anyone have a work-around?

To see the problem, take a look at: http://jsfiddle.net/StephenM/489aveLr/6/

If you zoom in on the rectangle covering Antarctica and use the mouse to pan around, you will see that the rectangle is only painted after the mouse button is release and the pan-animation has completed, whichever happens last.

I found some references to this behaviour in older versions of OpenLayers but it was apparently fixed in version 2, already. Why am I seeing it here? I have tested in Internet Explorer and both Chrome and Firefox and the behaviour is the same.

3

As @ahocevar mentioned in your ticket, there is a patch for this, and will be implemented in version 3.2.0. Until then, there is a buffer type approach, which can be used to render more of the vector layer than the viewport + 100px. It is called renderBuffer, and can be set as a property of the vector layer.

var vectorLayer = new ol.layer.Vector({
    source: new ol.source.Vector({
        features: [ new ol.Feature({ geometry: polygon }) ]
    }),
    renderBuffer: 1366
});

I set it to 1366, because that is the X axis resolution of my monitor, and this way, I can't scroll in an unrendered range. Or you can just merge the fix in your OpenLayers 3 library.

UPDATE:

I forgot about the pulling animation. This way, the resolution of the monitor will hardly make any sense, but a 5000px value did the magic for me. Although I didn't test the performance of this workaround, so it might be slow with complex layers.

  • 1
    Thank you. That works around the problem in the vast majority of the cases. What I really can't understand is why all these APIs (Leaflet too) render map tiles in real-time, on a delay, but don't re-draw geometries. Performance is the excuse but, if it isn't usable and the users don't like it, how does it help to be fast? – Xharlie Jan 13 '15 at 11:10
  • Contrary to OL2 and Leaflet OL3 does redraw geometries as you move, zoom, or rotate the map. But it redraws the geometries it already has (in the current "batch"). And it's when you release the mouse that new features/geometries are read from the vector source and rendered. This behavior could indeed be optional, but we have to see what the performance is when we recreate the batch more often. – erilem Jan 13 '15 at 22:30
  • 1
    We just added a updateWhileAnimating option to ol.layer.Vector. See github.com/openlayers/ol3/pull/2385. – erilem Jan 15 '15 at 20:06

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.