Select to view content in your preferred language

freehand drawing

555
2
03-31-2011 07:28 AM
ThaoNguyen
Emerging Contributor
I have different drawing tools that when drawing on map, graphics are selected.  The way I implement is after draw is completed, I run QueryTask and set query geometry to the drawing geometr?
I notice that when my drawmode = freehand, and I draw a circle, only graphics that are on the line are selected, the ones that inside circle are not selected because the QueryTask does not return graphics inside circle.
Is there a way to set the freehand to be filled or something so that I can select graphics inside circle line?

Thanks!
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
DrawMode.Freehand results to a polyline geometry. If your QueryTask need a polygon geometry, you can convert your polyline to polygon.

private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
 Polygon polygon = args.Geometry is Polygon ? args.Geometry  as Polygon: new Polygon();
 if (args.Geometry is Polyline)
 {
  Polyline source = args.Geometry as Polyline;
  foreach (var path in source.Paths)
   polygon.Rings.Add(path);
 }
 GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
 ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
 {
  Geometry = polygon,
  Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol
 };
 graphicsLayer.Graphics.Add(graphic);
}
0 Kudos
ThaoNguyen
Emerging Contributor
DrawMode.Freehand results to a polyline geometry. If your QueryTask need a polygon geometry, you can convert your polyline to polygon.

private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
 Polygon polygon = args.Geometry is Polygon ? args.Geometry  as Polygon: new Polygon();
 if (args.Geometry is Polyline)
 {
  Polyline source = args.Geometry as Polyline;
  foreach (var path in source.Paths)
   polygon.Rings.Add(path);
 }
 GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
 ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
 {
  Geometry = polygon,
  Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol
 };
 graphicsLayer.Graphics.Add(graphic);
}


Thank you!  That works!
I hope that in future drawmode will have both Freehand_Polyline and Freehand_polygon options.
0 Kudos