private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
{
MyDrawObject.IsEnabled = false;
ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
polygon.SpatialReference = MyMap.SpatialReference;
Graphic graphic = new Graphic()
{
Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
Geometry = polygon,
};
GeometryService geometryService =
new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
geometryService.AreasAndLengthsCompleted += GeometryService_AreasAndLengthsCompleted;
geometryService.Failed += GeometryService_Failed;
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.Graphics.Add(graphic);
List<Graphic> graphicList = new List<Graphic>();
graphicList.Add(graphic);
// Since there are multiple overloads for AreasAndLengthsAsync, make sure to use appropriate signature with correct parameter types.
geometryService.AreasAndLengthsAsync(graphicList, null, null, (CalculationType)CalcTypeListBox.SelectedValue);
// GeometryService.AreasAndLengths returns distances and areas in the units of the spatial reference.
// The units in the map view's projection is decimal degrees.
// Use the Project method to convert graphic points to a projection that uses a measured unit (e.g. meters).
// If the map units are in measured units, the call to Project is unnecessary.
// Important: Use a projection appropriate for your area of interest.
}