ArcEngine 绘制圆、线、面并显示其面积、长度
//画圆
IMap map = axMapControl1.Map;
IActiveView pActiveView = (IActiveView)map;
IGeometry pCir = axMapControl1.TrackCircle();
ISimpleFillSymbol pSimpleFillsym = new SimpleFillSymbolClass();
pSimpleFillsym.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
IFillShapeElement pCirEle = new ESRI.ArcGIS.Carto.CircleElementClass();
pCirEle.Symbol = pSimpleFillsym;
((IElement)pCirEle).Geometry = pCir;
IGraphicsContainer pContainer = map as IGraphicsContainer;
pContainer.AddElement((IElement)pCirEle, 0);
//以下为测面积功能
Double dArea;
IArea pArea = (IArea)pCir;
dArea = Math.Abs(pArea.Area);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
MessageBox.Show(dArea.ToString());
//画矩形
IMap map = axMapControl1.Map;
IActiveView pActiveView = (IActiveView)map;
IEnvelope pRec = axMapControl1.TrackRectangle();
ISimpleFillSymbol pSimpleFillsym = new SimpleFillSymbolClass();
pSimpleFillsym.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
IFillShapeElement pRecEle = new ESRI.ArcGIS.Carto.RectangleElementClass();
pRecEle.Symbol = pSimpleFillsym;
((IElement)pRecEle).Geometry = pRec;
IGraphicsContainer pContainer = map as IGraphicsContainer;
pContainer.AddElement((IElement)pRecEle, 0);
//以下为测面积功能
Double dArea;
IArea pArea = (IArea)pRec;
dArea = Math.Abs(pArea.Area);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
MessageBox.Show(dArea.ToString());
//画多边形
IMap map = axMapControl1.Map;
IActiveView pActiveView = (IActiveView)map;
IPolygon pPolygon = axMapControl1.TrackPolygon() as IPolygon;
ISimpleFillSymbol pSimpleFillsym = new SimpleFillSymbolClass();
pSimpleFillsym.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
IFillShapeElement pPolygonEle = new PolygonElementClass();
pPolygonEle.Symbol = pSimpleFillsym;
((IElement)pPolygonEle).Geometry = pPolygon;
IGraphicsContainer pContainer = map as IGraphicsContainer;
pContainer.AddElement((IElement)pPolygonEle, 0);
//以下为测距功能
Double dArea;
IArea pArea = (IArea)pPolygon;
dArea = Math.Abs(pArea.Area);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
MessageBox.Show(dArea.ToString());
转载自:https://blog.csdn.net/weixin_40578689/article/details/81103525