How to retrieve geometric shapes SketchEditor from GraphicsOverlay object

172
2
09-15-2020 07:38 AM
CavronJeremy
New Contributor III

Hi,

How to retrieve geometric shapes SketchEditor names from  GraphicsOverlay object ?

In SketchCreationMode I have Circle, Rectangle, etc.. type name.

I make shapes with SketchEditor.

I would like retrieve geometric shapes names from GraphicsOverlay object. It's possible?

I would like to have "Rectangle", "Circle", etc.. name.

Because when I try with GraphicsOverlay, I have only, "Polygon" or "Polyline" name.

Thanks

0 Kudos
2 Replies
ZackAllen
Esri Contributor

Hi Cavron. The geometry created by SketchEditor is created as Polygons, Points, or Polylines. If you want to keep the shape name, you can store the name as an attribute of the graphic.

This is modified code for the Sketch on map sample.

// Let the user draw on the map view using the chosen sketch mode
SketchCreationMode creationMode = (SketchCreationMode)SketchModeComboBox.SelectedItem;
Esri.ArcGISRuntime.Geometry.Geometry geometry = await MyMapView.SketchEditor.StartAsync(creationMode, true);

// Create and add a graphic from the geometry the user drew
Graphic graphic = CreateGraphic(geometry);

// Add the sketch creation mode as an attribute of the graphic.
graphic.Attributes["SketchCreationMode"] = Enum.GetName(typeof(SketchCreationMode), creationMode);

// Add the graphic to your graphics overlay.
_sketchOverlay.Graphics.Add(graphic);

Later, you can get the "Rectangle" name from the graphics attributes.

I hope this helps,

Zack

CavronJeremy
New Contributor III

Hi Zack,

Thank you for your answer. I will test.

0 Kudos