Ol3 modify interaction customization

I'm trying to create a ol.interaction.Modify() to adjust a bounding box's edges and position. In OpenLayers 2 I used TransformFeature Control and There were options to configure the transformation. How could the feature be modified in ol3 without changing the shape? I also want to add vertices as in ol2. If there's no other way then implementing a new interaction, could you provide some resources on how to do that?

As you found out already, there is nothing like a TransformFeature control in ol3 currently. However, it is quite easy to create a custom interaction that deals with specific feature modifications. For inspiration, you can look at the official drag-features example.

In your case, you will probably analyze the coordinate in thehandleDownEventfunction and determine the quadrant of your box and the proximity to the box corners. By doing so, you can conditionally set the behavior of thehandleDragEventfunction to either change one of the corner coordinates, or to drag the box as shown in the example.

Watch the video: MapStore 2 Comprehensive demo (October 2021).