ArcGIS Engine 中线段的绘制方法

时间:2022-07-22 09:00:11

ArcGIS Engine中线段的绘制


基本步骤

构建形状

1. 创建 IPoint
IPoint m_Point = new PointClass();
m_Point.PutCoords(x, y);

2. 创建 IPointCollection
IPointCollection m_PointCollection = new PolylineClass();
m_PointCollection.AddPoint(m_Point, ref Type.Missing, refType.Missing);

3. 创建 IPolyline
IPolyline m_Polyline = new PolylineClass();
m_Polyline = m_PointCollection as IPolyline;

4. 创建 IElement
// Element 不能实例化,需要用其派生类实例化
IElement m_Element = m_SimpleLineSymbol as IElement;
m_Element.Geometry = m_Polyline;

设置形状样式
1. 创建 ISimpleLineSymbol
ISimpleLineSymbol m_SimpleLineSymbol = newSimpleLineSymbolClass();

2. 创建 ILineElement
ILineElement m_LineElement = new LineElementClass();
m_LineElement.Symbol = m_SimpleLineSymbol;

加载到地图
IMap m_Map = axMapControl1.Map;
IActiveView m_ActiveView = m_Map as IActiveView;
IGraphicsContainer m_Container = m_Map as IGraphicsContainer;

m_Container.AddElement(m_Element, 0);

m_Active.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null,null);


-----------------------------------------------------------------------------------------------------------

其他方法

 

[csharp] viewplaincopyprint?
  1. private void DrawLine()  
  2.          
  3.             ILineElement pLineElement;  
  4.             IElement pLElement;  
  5.   
  6.             IPolyline pLine;  
  7.   
  8.             RgbColor pColor new RgbColor();  
  9.             pColor.Red 0;  
  10.             pColor.Green 0;  
  11.             pColor.Blue 255;  
  12.               
  13.             ISimpleLineSymbol pSimpleLineSymbol new SimpleLineSymbolClass();  
  14.             pSimpleLineSymbol.Color pColor;  
  15.             pSimpleLineSymbol.Width 5;  
  16.   
  17.             pLineElement new LineElementClass();  
  18.             pLineElement.Symbol pSimpleLineSymbol;  
  19.   
  20.             pLElement pLineElement as IElement;  
  21.   
  22.             IRubberBand pRubberBand;  
  23.             pRubberBand new RubberLineClass();  
  24.             pLine pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, nullas IPolyline;  
  25.   
  26.             pLElement.Geometry pLine;  
  27.   
  28.             IGraphicsContainer pGraphicsContainer;  
  29.             pGraphicsContainer axMapControl1.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器  
  30.               
  31.             pGraphicsContainer.AddElement(pLElement, 0);//把刚刚的element转到容器上  
  32.             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, nullnull);  
  33.         
复制去Google翻译翻译结果