AE+C#二次开发——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();
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值