Modifying features in an OpenLayers VectorLayer very slow after use

23 Views Asked by At

We have a somewhat large VectorLayer comprising mostly LineStrings and Points. After refreshing the browser and opening all our features at first, everything seems to move fine and dandy. However, after modifying a few features, a lot of the things we do is suddenly very slow. Most noticeably setting styles and dragging a feature.

I've looked into Chrome Performance DevTools and found something interesting. When a modification is done an event called handleFeatureChange is fired. At the start of the "session", that is after refreshing the browser, this event calls the functions removeFeature and addFeature perhaps one or two times. However, after modifying a few features here and there, those two functions are called loads of times, even if the LineString only contains like 3-4 points.

This seems to be a consistent behaviour between every slowdown we have, but I have no clue as to why the function is called more times.

Noticeably, panning and zooming is completely unaffected, so I do not think it is a result of using VectorLayer over VectorImageLayer or something similar.

I've been looking into issues and the source code for the modification event, but I haven't found anything to understand why a single handleFeatureChange all of a sudden should call removeFeature and addFeature any more times on the same feature when other features are modified.

I'll be happy to provide more information, but I'm not entirely sure what parts of our code that are interesting for this problem.

Thanks!

0

There are 0 best solutions below