Hi All

601
4
Jump to solution
05-06-2020 10:56 PM
bharathreddy
Occasional Contributor

Can we draw a line by selecting Point A and PointB on a existing polyline which is not a straghit line using arcgis javascript Api?

0 Kudos
1 Solution

Accepted Solutions
mdonnelly
Esri Contributor

To my knowledge, I don't believe there is anything in the API (3 or 4) that is going to do exactly what you want, out of the box.

I believe it would require some custom effort to achieve. Essentially you want to copy a polyline feature between 2 points, from what I understand.

You could do something like the following:

- Capture the start and endpoints from the user

- Intersect them with features from a given layer to find the closest feature

- Make a copy of that feature's geometry

- Edit the geometry to start and finish at the start and end points chosen by the user

- Apply those edits to your copy layer

Regards,
Mark

View solution in original post

0 Kudos
4 Replies
mdonnelly
Esri Contributor

Are you asking if the ArcGIS for JavaScript API has functionality that allows users to draw a line that automatically snaps to an existing polyline by just selecting the 2 endpoints?

If that is your question then I believe that it is not possible (out of the box).

Snapping is not currently implemented for editing under version 4 of the API:

Functionality matrix | ArcGIS API for JavaScript 4.15 

Under version 3, the Editor widget supports snapping but you would need to click on each of the polyline's vertexes to overlay your polyline exactly. You can see the Editor widget snapping in action at this line (press Cntrl to enable snap):

ArcGIS API for JavaScript Sandbox 

Mark

Regards,
Mark
0 Kudos
bharathreddy
Occasional Contributor

Hi Mark,

Can we achieve that functionality using  3.x ?

0 Kudos
mdonnelly
Esri Contributor

To my knowledge, I don't believe there is anything in the API (3 or 4) that is going to do exactly what you want, out of the box.

I believe it would require some custom effort to achieve. Essentially you want to copy a polyline feature between 2 points, from what I understand.

You could do something like the following:

- Capture the start and endpoints from the user

- Intersect them with features from a given layer to find the closest feature

- Make a copy of that feature's geometry

- Edit the geometry to start and finish at the start and end points chosen by the user

- Apply those edits to your copy layer

Regards,
Mark
0 Kudos
bharathreddy
Occasional Contributor

Thank you Mark.

0 Kudos