Arcgis 画线

12 篇文章 1 订阅

画线,首先得到线对象,要用到 IPointCollection 和    IPolyline 对象,

然后加载线元素IElement。

  /// <summary>
        /// 画线
        /// <param name="arrPointAll">点坐标数组</param>
        ///<returns></returns>
        private void DrawLine(ArrayList arrPointAll)
        {
            if (arrPointAll.Count <= 0)//点坐标数组不能为空
            {
                return;
            }

            if (activeView == null)
            {
                activeView = this.MapControl.ActiveView.FocusMap as IActiveView;
            }
            //删除以前的element
            DeleteOldElement(activeView.GraphicsContainer);

            // 获取IRGBColor接口
            IRgbColor color = new RgbColor();
            // 设置颜色属性
            color.Red = 255;
            color.Transparency = 255;
           
            //点
            IPoint pPoint = new PointClass();

            //线样式
            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Color = color;
            lineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame;
            lineSymbol.Width = 1;

            //线元素
            ILineElement lineElement = new LineElementClass();
            lineElement.Symbol = lineSymbol;

            //创建线
            IPolyline m_Polyline = new PolylineClass();
            //点集合
            IPointCollection m_PointCollection = new PolylineClass();
            //点数组
            ArrayList arrPoint = new ArrayList();
            object missing = Type.Missing;
            foreach (object o in arrPointAll)
            {
                arrPoint = (ArrayList)o;
                pPoint.PutCoords(int.Parse(arrPoint[0].ToString()), int.Parse(arrPoint[1].ToString()));
                m_PointCollection.AddPoint(pPoint, ref missing, ref missing);
            }

            //QI for IPolyline
            m_Polyline = m_PointCollection as IPolyline;

            //放大地图

            //折线范围
            IEnvelope pEnvelope = m_Polyline.Envelope;
            //折线区域
            IArea pArea = pEnvelope as IArea;
            pPoint = pArea.Centroid;

            this.ChangeEnvelope(pPoint, 0.06, 0.06);
            //QI for IElement
            IElement element = lineElement as IElement;
   
            element.Geometry = m_Polyline;

            //加载线元素到地图
            activeView.GraphicsContainer.AddElement(element, 0);
            //Refresh the graphics
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值