private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { //ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline; args.Geometry.SpatialReference = MyMap.SpatialReference; Graphic graphic = new Graphic() { Geometry = args.Geometry }; if (args.Geometry is Polyline) { graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; } else { graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; } graphicsLayer.Graphics.Add(graphic); if (graphicsLayer.Graphics.Count == 1) { MyDrawObject.DrawMode = DrawMode.Point; } else if (graphicsLayer.Graphics.Count == 2) { MyDrawObject.IsEnabled = false; GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.DistanceCompleted += GeometryService_DistanceCompleted; geometryService.Failed += GeometryService_Failed; MyDrawObject.DrawMode = DrawMode.Polyline; DistanceParameters distanceParameters = new DistanceParameters() { DistanceUnit = LinearUnit.SurveyMile, Geodesic = true }; geometryService.DistanceAsync(graphicsLayer.Graphics[0].Geometry, graphicsLayer.Graphics[1].Geometry, distanceParameters); ResponseTextBlock.Text = "The distance between geometries is... "; } }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { //ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline; args.Geometry.SpatialReference = MyMap.SpatialReference; Graphic graphic = new Graphic() { Geometry = args.Geometry }; graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphic); if (graphicsLayer.Graphics.Count == 2) { MyDrawObject.IsEnabled = false; GeometryService geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.DistanceCompleted += GeometryService_DistanceCompleted; geometryService.Failed += GeometryService_Failed; DistanceParameters distanceParameters = new DistanceParameters() { DistanceUnit = LinearUnit.SurveyMile, Geodesic = true }; geometryService.DistanceAsync(graphicsLayer.Graphics[0].Geometry, graphicsLayer.Graphics[1].Geometry, distanceParameters); ResponseTextBlock.Text = "The distance between the points is... "; ESRI.ArcGIS.Client.Geometry.PointCollection points = new ESRI.ArcGIS.Client.Geometry.PointCollection(); points.Add(graphicsLayer.Graphics[0].Geometry as MapPoint); points.Add(graphicsLayer.Graphics[1].Geometry as MapPoint); ESRI.ArcGIS.Client.Geometry.Polyline polyline = new ESRI.ArcGIS.Client.Geometry.Polyline(); polyline.Paths.Add(points); Graphic linegraphic = new Graphic() { Geometry = polyline, Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; lineLayer.Graphics.Add(linegraphic); } MyDrawObject.IsEnabled = true; }
static public void DistanceIsValid(Graphic G1, Graphic G2) { DistanceParameters distanceParameters = new DistanceParameters() { DistanceUnit = LinearUnit.Meter, Geodesic = true }; if (_geometryTask == null) { LocalGeometryService.GetServiceAsync(lgs => { _geometryTask = new GeometryService(); _geometryTask.Url = lgs.UrlGeometryService; _geometryTask.DistanceCompleted += GeometryService_DistanceCompleted; _geometryTask.Failed += GeometryService_Failed; }); } _geometryTask.DistanceAsync(G1.Geometry, G2.Geometry, distanceParameters); }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { args.Geometry.SpatialReference = MyMap.SpatialReference; Graphic graphic = new Graphic(){ Geometry = args.Geometry }; if (args.Geometry is Polyline) graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; else graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphic); if (graphicsLayer.Graphics.Count == 1) MyDrawObject.DrawMode = DrawMode.Point; else if (graphicsLayer.Graphics.Count == 2) { MyDrawObject.IsEnabled = false; GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.DistanceCompleted += GeometryService_DistanceCompleted; geometryService.Failed += GeometryService_Failed; MyDrawObject.DrawMode = DrawMode.Polyline; DistanceParameters distanceParameters = new DistanceParameters() { DistanceUnit = LinearUnit.SurveyMile, Geodesic = true }; geometryService.DistanceAsync(graphicsLayer.Graphics[0].Geometry, graphicsLayer.Graphics[1].Geometry,distanceParameters); ResponseTextBlock.Text = "The distance between geometries is... "; } }