I'm having a bit of an issue passing the graphics from my Identity Task to GeometryService_BufferCompleted. I'm guessing I might not have my BufferParameters in the right spot? I've spent a few hours trying to figure it out, but no luck yet. Also, I will be potentially buffering points/lines/polygons - do I need to make any changes for this? I realize that each time it goes through the loop, a feature will be buffered. There will generally only be 4-5 selected at a time maximum so processing time shouldnt be an issue. Will this be an issue with unioning my buffer results? Ultimately I want a single unioned buffer polygon which I can use later on.
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
{
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
if (args.IdentifyResults.Count > 0)
{
foreach (IdentifyResult result in args.IdentifyResults)
{
Graphic graphic = result.Feature;
switch (graphic.Attributes["Shape"].ToString())
{
case "Polygon":
graphic.Symbol = DefaultFillSymbol;
break;
case "Polyline":
graphic.Symbol = DefaultLineSymbol;
break;
case "Point":
graphic.Symbol = DefaultMarkerSymbol;
break;
}
GeometryService geometryServiceSSL =
new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
geometryServiceSSL.BufferCompleted += GeometryService_BufferCompleted;
geometryServiceSSL.Failed += GeometryService_Failed;
graphic.SetZIndex(1);
graphicsLayer.Graphics.Add(graphic);
//test
// If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
BufferParameters bufferParams = new BufferParameters()
{
Unit = LinearUnit.Meter,
BufferSpatialReference = new SpatialReference(4326),
OutSpatialReference = MyMap.SpatialReference,
UnionResults = true
};
bufferParams.Features.Add(graphic);
bufferParams.Distances.Add(5000);
geometryServiceSSL.BufferAsync(bufferParams);
//test
}
}
else
{
//do nothing
}
}
Here is the code for my Buffer - no graphic features are being passed as I can see from results.count always being 0.
void GeometryService_BufferCompleted(object sender, GraphicsEventArgs args)
{
IList<Graphic> results = args.Results;
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
//this tests to see if anything is carried over in results
MessageBox.Show("count is " + args.Results.Count);
foreach (Graphic graphic in results)
{
graphic.Symbol = DefaultFillSymbol;
graphicsLayer.Graphics.Add(graphic);
}
}
Thanks for any ideas!EDIT - I'm moving ahead temporarily and have set up different IdentifyParameters to base my 2nd Identify on the Buffered Polygon. How do I go about setting the Geometry of my new IdentifyParameters to the Buffered Polygon which I will have created?