Performance on multiple ol.Feature changes with cluster + ol.Collection

23 views
Skip to first unread message

Silviu Negoita

unread,
Jun 19, 2017, 9:47:29 AM6/19/17
to OpenLayers Dev
I have ol.source.Cluster with ol.source.Vector as a source with ol.Collection as features property of the vector source.

Every second a do a request to server to get some updates which leads to bulks of operations like  push/remove/geometry edits on given ol.Collection

The problem is because for every single(one by one) mentioned action, ol.Colection ol.Feature triggers an event(add, remove, change) which is caught eventualy by the cluster which makes an internal extensive task - ol.source.Cluster.prototype.refresh_(). A solution is to add methods(e.g. ol.Collection.silentPush(), ol.geom.*.silenceSetCoordinates()) which doesn't trigger these events or capabilities to remove the default events on  ol.Collection or ol.Feature, and let the user to manual make a refresh after all operations are made. In this case all changes would be processed at once, not one by one => reducing the number of ol.source.Cluster.refresh_() calls. 

I saw a similar problem here but he might solve his problem using arrays instead of olCollection. I cannot do this, because i don't replace all features with new ones, but just edit a part of them.
I also posted on SO here, where i tried to find out how to remove certain default event listeners.

Any other ideas, how to reduce this performance impact?
Reply all
Reply to author
Forward
0 new messages