void queryTask_ExecuteCompleted(object sender, QueryEventArgs e)
{
foreach (Graphic item in e.FeatureSet.Features)
{
Graphic queryGraphic = new Graphic();
ESRI.ArcGIS.Client.Geometry.MapPoint mapPnt = new MapPoint(item.Geometry.Extent.XMax, item.Geometry.Extent.YMax);
queryGraphic.Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(mapPnt);
queryGraphic.Geometry.SpatialReference = sReference;
BufferParameters bufferParams = new BufferParameters()
{
BufferSpatialReference = new SpatialReference(102100),
OutSpatialReference = MapaGM.SpatialReference,
Unit = LinearUnit.Meter,
};
bufferParams.Distances.Add(1000);
bufferParams.Features.Add(queryGraphic);
geometryService.BufferAsync(bufferParams);
}
}
void geometryService_BufferCompleted(object sender, GraphicsEventArgs e)
{
Graphic bufferGraphic = new Graphic();
bufferGraphic.Geometry = e.Results[0].Geometry;
bufferGraphic.Symbol = LayoutRoot.Resources["BufferSymbol"] as Symbol;
bufferGraphic.SetZIndex(1);
pointAndBufferGraphicsLayer.Graphics.Add(bufferGraphic);
}
Solved! Go to Solution.
You should be able to pass all the features returned from the QueryTask to the Buffer. The code below works for me
void QueryTask_ExecuteCompleted(object sender, QueryEventArgs e)
{
FeatureSet fs = e.FeatureSet;
if (fs.Count() == 0)
{
MessageBox.Show("Sorry, no data matches your query. Please try again", "Query Error", MessageBoxButton.OK);
}
else
{
BufferParameters buffParam = new BufferParameters() {
Unit = LinearUnit.Meter,
BufferSpatialReference = _Map.SpatialReference,
OutSpatialReference = _Map.SpatialReference
};
buffParam.Distances.Add(500);
buffParam.Features.AddRange(fs.Features);
GeometryService geoService = new GeometryService("http://<servername>/ArcGIS/rest/services/Geometry/GeometryServer");
geoService.BufferCompleted += (send,args) =>
{
GraphicsLayer gl = (GraphicsLayer)_Map.Layers[_GraphicsLayer];
gl.ClearGraphics();
gl.Renderer = LayoutRoot.Resources["SelectRendererPoly"] as IRenderer; //polygon renderer defined in XAML
foreach (var g in args.Results)
{
gl.Graphics.Add(g);
}
gl.Refresh();
};
geoService.BufferAsync(buffParam);
}
}
You should be able to pass all the features returned from the QueryTask to the Buffer. The code below works for me