2

For OpenLayers2, there are nice examples which show how to create vector features and edit them (adding vertices, moving them, ...), e.g. http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/modify-feature.html

Is it possible to reproduce this functionality in OpenLayers3? On the official website, I was only able to find an example which shows how to create vector features but not how to edit them: http://ol3js.org/en/master/examples/draw-features.html

2 Answers 2

3

The mechanism for modifying features in OpenLayers 3, similar to OpenLayers.Control.ModifyFeature in OpenLayers 2, has been added to the trunk and is called ol.interaction.Modify. Here is an example of modifying features only.

There is also a an example of combining draw and modify together, which uses an ol.FeatureOverlay, rather than ol.source.Vector, so that this can be passed to both the constructors for ol.interaction.Modify and ol.interaction.Draw, so that they can operate on the same vector objects and be simultaneously enabled. There is a method that looks for a shift press and single click to enable deleting a vertex.

1

I think I might have found the unfortunate answer that this is currently not possible:

https://groups.google.com/forum/#!msg/ol3-dev/HP1by77TZJ0/qiVEaTCkf_EJ:

On Mon, Jan 6, 2014 at 5:34 PM, Christophe Damour via OL3 Dev wrote:

Hi Eric,

I gave a try to vector-api branch, and it looks great, but I got stuck trying to add draw and modify interactions which doesn't seem to be implemented in this branch :-)

Is there an alternative ? Or have I missed something ?

You haven't missed anything. This is currently under development.

4

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.