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. }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { 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.FillSymbol, Geometry = polygon, }; GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.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); geometryService.AreasAndLengthsAsync(graphicList); // 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. }
private void DoMesurement(Graphic graphic) { List <Graphic> graphicList = new List <Graphic>(); graphicList.Add(graphic); if (widgetConfig.AlwaysProject || this.CurrentPage.MapUnits == ScaleLine.ScaleLineUnit.DecimalDegrees) { geometryService.ProjectAsync(graphicList, new SpatialReference(widgetConfig.ProjectToWKID)); } else { switch (this.measurementMode) { case MODE_LENGTH: geometryService.LengthsAsync(graphicList, this.CurrentPage.MapUnits); break; case MODE_AREA: geometryService.AreasAndLengthsAsync(graphicList, this.CurrentPage.MapUnits); break; } } }
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. }