I'm developing an application where the user can view and edit a street grid of a city. The streets are presented as features on a vector layer, and the user has to be able to modify the elements (both the attributes and the geometry - which is LineString - of the feature). The editing of a geometry is limited to dragging the end points of the LineString, at least for now.

The trick is that the new end points must intersect with the current geometry of the feature, so that the user cannot drag a road to start from outside of the street grid. Also, modifying the geometry should affect the neighbouring geometries, if any. That is, if another road begins where one ends, both should have their start/end point changed.

I don't suppose OpenLayers supports this out of the box so how should I begin to implement this?

  • did you try to use snapping with openlayers?
    – urcm
    Jan 15, 2013 at 7:57
  • I believe one can only snap to other elements, not to "itself". However, I suppose it would be possible to temporarily clone the feature to another vector layer, use the snapping feature to snap the clone to its original feature and then clone back the modified feature to the original layer. That wouldn't solve the problem with modifying the neighbouring geometry though.
    – mrLite
    Jan 15, 2013 at 8:09
  • Its a good question. Upvote.
    – Magno C
    Jan 15, 2013 at 10:04
  • I used to use a custom coded proprietary editor that could do this and it used open source libraries, which ones I don't know, unfortunately. It was very handy though, used by a company called GDT
    – lewis
    Feb 5, 2013 at 19:39

1 Answer 1


Maybe this can be useful: https://github.com/jorix/OL-GhostNodes ,

see example: http://jorix.github.com/OL-GhostNodes/examples/ghost-nodes.html

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.