Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

When using the modify feature functionality of OpenLayers, I get the option to move the individual vertices around.

But I also get a set of virtual vertices - each vertex located on the edge between the original vertices. The virtual vertices allow me to kind of locally subdivide the existing polygon.

enter image description here

I can see that this feature is neat, but in many situations I don't want the user to be able to do local subdivision of the polygon - I want to maintain the original set of vertices while allowing the user to change the position of each of the vertices.

Is that possible with the existing OpenLayers controls?

share|improve this question
add comment

2 Answers

The vertices are stored in two different properties of the ModifyFeature control - virtual vertices and vertices.

You could check which group the vertex belonged to in the dragVertex event, and if it is in the virtual vertex array then ignore it.

If you also set the virtualStyle of the control then these virtual vertices will be invisible.

Alternatively you could add an event handler for the selectFeature function and destroy the vertices with code similar to:

myControl.layer.removeFeatures(myControl.virtualVertices, {silent: true});
myControl.virtualVertices = [];

Ignoring drags on the virtual vertices, and hiding them from the user may be simpler to implement though.

share|improve this answer
    
Even though I set a transparent virtualStyle I'll still get the move cursor when hovering a virtual vertex - right? I don't get though, why they haven't included a boolean useVirtualVertices. I could add it my self, but I would have to maintain it when upgrading OpenLayers. –  Chau Mar 8 '11 at 10:05
    
You could always extend the control to add this functionality so you would not have to worry (or worry less) about upgrades. Did you try the cursor property of the virtualStyle? –  geographika Mar 8 '11 at 10:40
    
I haven't tried the cursor property. I am still at the planning phase and just wanted to hear if the answer to my question is yes or if I need to take another route. –  Chau Mar 8 '11 at 11:54
    
Obviously, the answer is yes. Geographika gave you already many informations to prove/do it. –  simo Mar 9 '11 at 8:25
add comment

Just set createVertices on your ModifyFeature control to false.

Example:

    var modifyControl = new OpenLayers.Control.ModifyFeature(vectorLayer);
    modifyControl.createVertices = false;

Here is a live demo.

share|improve this answer
    
I seems like it is supported now, it wasn't more than two years ago when I posted the question :) Thanks for informing us! –  Chau Dec 2 '13 at 10:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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