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.

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
add comment

2 Answers 2

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
add comment

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
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.