Select to view content in your preferred language

Split Line JavaScript API

4825
5
04-19-2016 09:16 AM
jaykapalczynski
Honored Contributor

Is there any code reference to allow a user to select a line segment and then click a point along that selected line segment to split the line into two pieces?  split location is user defined by a click.....

0 Kudos
5 Replies
DavidBlanchard
Esri Contributor

You can use the API's geometry engine, which has a cut method:

esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript

The user will need to draw a line rather than just clicking to create a point, but it works in the same way.

0 Kudos
jaykapalczynski
Honored Contributor

Any working examples of this?  or a jsfiddle?

0 Kudos
jaykapalczynski
Honored Contributor

I was trying to example but it looks like it cuts and only keeps the right side?  Need both parts kept....

example:  Edit fiddle - JSFiddle

I did see your example Wee Yeo...this is doing exactly what I want....although its a polygon...

example: Geometry Engine Showcase

1.  does this work for polylines as well?

2. I have not grabbed code from Github before.....it looks like the above exmaple is using the "ge-demo"  how do I grab this and bring it to my server?

0 Kudos
jaykapalczynski
Honored Contributor

Any thoughts on my last post...the example did not seem to keep both portions on the line it was splitting....seemed to jsut be cutting it and ditching the other portion.

0 Kudos