2

THIS QUESTION IS STILL OPEN AND OF INTEREST


Openlayers: 4.6.5


I have a Modify Interaction and two active Select Interactions. The Modify Interaction is instantiated like this:

   var interaction = new ol.interaction.Modify({
     source: myLayer.getSource()
   });

When I click the edge of a polygon feature, a vertex of this polygon is highlighted - when I draw, the vertex is moved and when I release, the MODIFYEND is triggered. There is obviously exactly one feature affected.


After Modifying a Feature Geometry with the Modify Interaction, I expect the triggered modifyend event to provide the feature or the geometry that has been affected by the modification. However, it only provides me an ol.Collection containing ALL Features of the interaction's source.

How can I obtain the feature then?

interaction.on(ol.interaction.ModifyEventType.MODIFYEND,function(event) {

    // event does not have a feature property

});

Edit: I totally want to avoid this: I found this as a working solution, but I am not happy about it and I don't think this is the appropriate way:

interaction.on(ol.interaction.ModifyEventType.MODIFYEND,function(event) {

       var featureModified = interaction.dragSegments_[0][0].feature;

    });</s>
8
  • 2
    see gis.stackexchange.com/questions/175784/…
    – Mike
    Commented Jul 17, 2019 at 11:54
  • Unfortunately, that thread does not answer the question
    – Lokomotywa
    Commented Jul 17, 2019 at 11:55
  • "You can always use a select interaction and the pass the selected feature to modify interaction" answers it perfectly. See codepen.io/anon/pen/jgNGVQ When you click on a country and modify its outline the country info is shown. toggleCondition: ol.events.condition.never is set in the select interaction so only one feature can be selected at a time.
    – Mike
    Commented Jul 17, 2019 at 12:34
  • I already have an active Select Interaction that I use for other purposes, so basically no.
    – Lokomotywa
    Commented Jul 17, 2019 at 13:30
  • Based on stackoverflow.com/questions/45842671/… this avoids using a select interaction codepen.io/anon/pen/eqOLJV
    – Mike
    Commented Jul 17, 2019 at 16:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.