private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { _gpTask.CancelAsync(); GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); e.MapPoint.SpatialReference = MyMap.SpatialReference; Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); // Build paramaters List<GPParameter> gpParams = new List<GPParameter>(); double dist = System.Convert.ToDouble(500); // Old code from Buffer sample (single graphic approach) //var g = new Graphic { Geometry = e.MapPoint }; //var fs = new FeatureSet(new List<Graphic> { g }); List<Graphic> graphicsList = new List<Graphic>(); Random random = new Random(); for (int i = 0; i < 5; i++) { var g = new Graphic { Geometry = new MapPoint(random.Next(-20000000, 20000000), random.Next(-20000000, 20000000), MyMap.SpatialReference), }; graphicsList.Add(g); } var fs = new FeatureSet(graphicsList); gpParams.Add(new GPFeatureRecordSetLayer("InputFeatures", fs)); gpParams.Add(new GPLinearUnit("Distance", esriUnits.esriKilometers, dist)); _gpTask.ExecuteCompleted += (s, e1) => { GPExecuteResults results = e1.Results; GPFeatureRecordSetLayer rs = results.OutParameters[0] as GPFeatureRecordSetLayer; List<Graphic> resultGraphics = new List<Graphic>(); for (int i = 0; i < rs.FeatureSet.Features.Count; i++) { Graphic graphicBuff = new ESRI.ArcGIS.Client.Graphic() { Geometry = rs.FeatureSet.Features.Geometry, Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; resultGraphics.Add(graphicBuff); } graphicsLayer.Graphics.AddRange(resultGraphics); }; _gpTask.Failed += (s2, e2) => { MessageBox.Show(e2.Error.Message); }; _gpTask.ExecuteAsync(gpParams); }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.