Select to view content in your preferred language

How do i update the geometry of polyline?? once i created it, and add it to the graphics layer.

4854
6
Jump to solution
11-25-2014 06:04 AM
ShaharBukra
Regular Contributor

i have no idea how i can implement it...

does anyone have an idea?

how to access the point list or anything else.

thanks

0 Kudos
1 Solution

Accepted Solutions
AnttiKajanus1
Deactivated User

Sorry I missed that part from the last reply. Easiest way is to use PolylineBuilder class. It works basically like StringBuilder.

PolylineBuilder builder = new PolylineBuilder(polyline); // Create new builder from existing polyline
builder.AddPoint(new MapPoint(x3, y3, polyline.SpatialReference)); // how to add new point to end of the polyline
builder.Parts[0][1] = new MapPoint(x3, y3, polyline.SpatialReference); // how to change one specific point in the polyline 
graphic.Geometry = builder.ToGeometry(); // create new polyline from the builder

View solution in original post

0 Kudos
6 Replies
AnttiKajanus1
Deactivated User

Please see guide documentation : Edit features—ArcGIS Runtime SDK for .NET | ArcGIS for Developers and online sample Code Example - Editor_Sketching  or https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/master/src/Desktop/ArcGISRuntimeSDKDotNet...‌ sample from samples reporsitory.

Key points here are using Editor class to edit existing geometry and then save that to geodatabase / feature service if needed.

Please let me know if you have following questions.

0 Kudos
ShaharBukra
Regular Contributor

HI,

Thanks for your answer but...

i dont want to save it for any local saving,

i want to change the one point of the line,

if i have line with point [(x1,y1),(x2,y2)] i want to edit it in code to be [(x1,y1),(x3,y3)]

0 Kudos
AnttiKajanus1
Deactivated User

In that case you can create new Polyline and replace Graphic.Geometry with that one. In ArcGIS Runtime for .NET, geometries are immutable object so you can just replace the exiting geometry with new one.

So on higher level you can do it like this

Graphic graphic = GetMyWorkingGraphic(); // existing Graphic with geometry that you want to replace / edit
Polyline polyline = CreateNewPolylineWithChanges(); // create new geometry with the changes
graphic.Geometry = polyline; // set geometry with changes to the graphic

To see how to create geometries in code, please see samples

arcgis-runtime-samples-dotnet/CreatePolylines.xaml.cs at master · Esri/arcgis-runtime-samples-dotnet...

arcgis-runtime-samples-dotnet/CreatePolygons.xaml.cs at master · Esri/arcgis-runtime-samples-dotnet ...

arcgis-runtime-samples-dotnet/CreatePoints.xaml.cs at master · Esri/arcgis-runtime-samples-dotnet · ...

0 Kudos
ShaharBukra
Regular Contributor

Thanks Antti!

I understand what you say,

Do you have any idea how to take my current polyline and extract the points from it?

thanks again!

Shahar.

0 Kudos
AnttiKajanus1
Deactivated User

Sorry I missed that part from the last reply. Easiest way is to use PolylineBuilder class. It works basically like StringBuilder.

PolylineBuilder builder = new PolylineBuilder(polyline); // Create new builder from existing polyline
builder.AddPoint(new MapPoint(x3, y3, polyline.SpatialReference)); // how to add new point to end of the polyline
builder.Parts[0][1] = new MapPoint(x3, y3, polyline.SpatialReference); // how to change one specific point in the polyline 
graphic.Geometry = builder.ToGeometry(); // create new polyline from the builder
0 Kudos
ShaharBukra
Regular Contributor

Thanks, it helped a lot

0 Kudos