I'm new to OpenLayers, and I am developing a basic editor using it. I can place different kind of icons (points) or paths (lines).

An "edit" tool is required. It is supposed to allow you to modify the line path, and move the icons position. However, this is where I am facing problems. To move a point DragFeature must be used, and to edit a line ModifyFeature should be the one.

image sample here

In this approach, both controls have the same tool, and I am not being able to modify a line or drag a point with the same tool. What I tried, was to use the select control instead. Once a feature is selected, according to its type, I can swap to the appropriate control (drag or modify). However, this technique is far for from perfect, since then, two clicks are required in the feature to start dragging it. The first click, is used by the select feature to capture the event and activate the DragFeature control, and the second one is to start dragging.

I would like to be able to drag a feature with one single click, and be able to edit a line with one single click.

Can anyone help me?

1 Answer 1


I think you need this. Combining those two tools can be a solution, but if you split these two tasks in two icons/individual approaches you could have a cleaner code and probably you will spend less time debugging it. "Divide and conquer" may apply quite well here


Your Answer

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

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