I would like to programmatically draw a polygon on an ESRI map. I'm using this code to draw a polygon with the mouse but I'm really new to this technology and I'm a little bit lost ... Here is my MainWindow :
public partial class MainWindow : Window
{
Draw _myDrawObject;
private GraphicsLayer _graphicsLayer;
public MainWindow()
{
InitializeComponent();
_myDrawObject = new Draw(esriMap)
{
FillSymbol = LayoutRoot.Resources["RedFillSymbol"] as FillSymbol
};
_myDrawObject.DrawComplete += MyDrawObjectDrawComplete;
}
private void EsriMapMouseClick(object sender, Map.MouseEventArgs e)
{
_myDrawObject.DrawMode = DrawMode.Polygon;
_myDrawObject.IsEnabled = true;
}
private void MyDrawObjectDrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
var graphic = new Graphic()
{
Geometry = args.Geometry,
Symbol = LayoutRoot.Resources["BlueFillSymbol"] as FillSymbol
};
_graphicsLayer = esriMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
if (_graphicsLayer != null)
_graphicsLayer.Graphics.Add(graphic);
}
I already went to the ArcGIS help site (http://resources.arcgis.com/content/web-based-help) but i can't find the solution. Any ideas or tips ?
Feel free to ask me some questions if you want more details!
