ArcEngine在AxMapControl上绘制

在AxmapControl上绘制点(point)线(line,polyline)都是比较方便的,函数如下:

        /// <summary>
        /// 在地图控件上绘制点或线
        /// </summary>
        /// <param name="IN_Symbol">绘制符号</param>
        /// <param name="IN_Geometry">绘制的图形</param>
        /// <param name="IN_AxmapControl">地图控件</param>
        private void PRV_DrawOnMapControl(ISymbol IN_Symbol,IGeometry IN_Geometry,AxMapControl IN_AxmapControl)
        {
            //定义绘图容器
            IGraphicsContainer Temp_GraphicsContainer = IN_AxmapControl.Map as IGraphicsContainer;
            //设定参数
            IElement Temp_TargetElement=new LineElementClass();//默认线元素
            switch (IN_Geometry.GeometryType)
            {
                case esriGeometryType.esriGeometryPoint:
                    IMarkerElement Temp_MarkerElement = new MarkerElementClass();
                    //设定符号
                    Temp_MarkerElement.Symbol = IN_Symbol as IMarkerSymbol;
                    Temp_TargetElement = Temp_MarkerElement as IElement;
                    Temp_TargetElement.Geometry = IN_Geometry;
                    break;
                case esriGeometryType.esriGeometryLine:
                    //将Line转换成PolyLine
                    object Missing1 = Type.Missing;
                    object Missing2 = Type.Missing;
                    ISegment Temp_Segment = IN_Geometry as ISegment;
                    PolylineClass Temp_Polyline = new PolylineClass();
                    Temp_Polyline.AddSegment(Temp_Segment, ref Missing1, ref Missing2);
                    //绘制PolyLine
                    ILineElement Temp_LineElement = new LineElementClass();
                    Temp_LineElement.Symbol = IN_Symbol as ILineSymbol;
                    Temp_TargetElement = Temp_LineElement as IElement;
                    Temp_TargetElement.Geometry = Temp_Polyline;
                    break;
                case esriGeometryType.esriGeometryPolyline:
                    ILineElement Temp_PolyLineElement = new LineElementClass();
                    Temp_PolyLineElement.Symbol = IN_Symbol as ILineSymbol;
                    Temp_TargetElement = Temp_PolyLineElement as IElement;
                    Temp_TargetElement.Geometry = IN_Geometry;
                    break;
            }
            //绘制
            Temp_GraphicsContainer.AddElement((IElement)Temp_TargetElement, 0);
            //刷新显示
            IN_AxmapControl.ActiveView.Refresh();
        }


你可能感兴趣的:(绘图,ArcEngine,ArcgisEngine)