5

I would like to know if the ArcGIS Javascript API has built in snapping functionality for the measure tool. I am trying to create a measure tool which only measures distances along the edge of roads. Is there anything built-in or would I need to create this functionality by linking into ArcObjects?

  • Alternatively, what would I need to do to create this functionality? – jvangeld Mar 22 '11 at 17:54
5

Not sure it did when the question was first asked but it sure does now.

Check the sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_measurement

2

I think you'll need to write your own custom tool. I don't see a method in the REST API that returns a point and feature ID that is closest to a specified point. You could use a query request, but then you'd have to use javascript to loop through the returned features to find the closest point on the closest feature relative to the point where the user clicked. Personally, I think it would be easier to write a REST based SOE, but only because my C# is better than my javascript.

2

Based on my observation of how the Silverlight SDK works (which has snapping), I believe you will have to write your own snapping implementation. I don't think there's anything on the server that will really help you.

You will have to retrieve the geometries associated with the road(s) you want to measure via the FeatureServer. Then on the measure tool, you'll have to enable a mouse listener to search the vertexes of the visible geometries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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