OpenLayers 3 modify end event

OpenLayers 3 modify end event

I want to save the geometry data after I modify it, so I need an event that fire after I finish to modify the feature. I use the following from this post: listener modify interaction

var selected_features = select.getFeatures(); // when a feature is selected… selected_features.on('add', function (event) { // get the feature var feature = event.element; feature.on("change", function (event) { logStatus(feature.getId() + " has been changed!
"); }); });

But this listener fires too many times in a single modification, and if I am using 'once' instead of 'on' its fires only the first little change and no more, so its not saving the real change. I need something like "changeend" or "modifyend" that will fire when I will finish to modify the feature, what can i use?

If you need a modifyend event why dont you use it within the modify interaction.(I guess you use a modify interaction) check this

modify.on('modifyend',function(e){ console.log("feature id is",e.features.getArray()[0].getId()); });

This event is available in the latest versions of ol3. In my code snip, I assume you only modify one fetaure at once (getArray()[0]) . If you use more than one fetaure to modify at once then get the fetaures array and add a loop for further manipulation. Like so:

modify.on('modifyend',function(e){ var features = e.features.getArray(); for (var i=0;i

Watch the video: Openlayers 6 Tutorial #7 - Vector Layers