I add the function drag on a feature that I draw, but OpenLayers 4 seems that when you modify a feature, the new index of the one you modify now is different.
How can I remove that function from the core? or exist an alternative to prevent this?
This is what I use to add the drag function.
$("#markdrag").click(function(e) { e.preventDefault(); var sel = document.getElementById('tlfeature'); // get ID of the current marker var ids = sel[sel.selectedIndex].id; var dragInteraction = new ol.interaction.Modify({ features: new ol.Collection([Msource.getFeatures()[ids]]), style: null }); }); Where IDS is the index of the feature, but if I draw 2 features and drag the 1st at the end of the interaction the index is now 1 and not 0.
I need to work on Index because when I draw a marker I have a function that:
populates the drop-down menu with the marker (name = Marker + source index) add a Textarea (bind to the marker ID(source index) so when you change the marker you have a related Textarea) I'm working on this events to create all of these.
drawLayer.on("change", function(){ // remove the interaction when you plot one marker map.removeInteraction(draw); }); // occurs when you finish to draw the current element draw.on("drawend", function(){ // function to create everything drawing(); }) 