Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a DrawFeature control that I want use to draw a line between two features (on a separate layer from the lines). I use a Snapping control to snap the cursor to the features.

Any ideas on how can the drawing be limited so that it only allows to end the line on a feature?

Illustration (O represents a feature):

O---O allowed
O---  not allowed
 ---  not allowed
share|improve this question
up vote 1 down vote accepted

When drawing of the line is completed (or on end of every segment) check to see if it intersects with a feature, and in your case it should intersect with 2 features. Unless it can loop back onto the same feature and touch it twice. And you can do additional checks to make sure the intersecting feature is a Polygon and not another line...or whatever other rules you have to suffice.

share|improve this answer

A poor man's way of doing this could be to turn the resolution up quite high, larger than the on screen pixels in the map, and play with the greedy flag, so that it always snaps to something.

Otherwise you just leave it as is, but have a function triggered after each new line is draw which checks if it is good and removes it if it isn't touching two features.

share|improve this answer

Your Answer


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.