mapinfo开发 >> MapXtreme添加标注

最后编辑时间:2021年07月19日 17:05:19

【内容简介】这里我们研究一下:MapXtreme添加标注,MapXtreme添加点,MapXtreme添加折线,MapXtreme添加多边形面图元,等等。

        //MapXtreme添加点
        public void DrawPoint(DPoint p, double size, Color color)
        {
            MapInfo.Geometry.Point point = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), p);
            SimpleVectorPointStyle style = new SimpleVectorPointStyle();
            style.PointSize = size;
            style.Color = color;
            Draw(point, style);
        }

        //MapXtreme添加折线,可以是直线、折线等
        public void DrawLine(DPoint[] points)
        {
            SimpleLineStyle style = new SimpleLineStyle();
            style.Color = Color.FromArgb(255, 0, 0);
            style.Width = new LineWidth(5, LineWidthUnit.Pixel);
            style.SetApplyAll();
            //折线
            MultiCurve multiCurve = new MultiCurve(map.GetDisplayCoordSys(), CurveSegmentType.Linear, points);
            Draw(multiCurve, style);
        }
           //MapXtreme添加矩形面图元,当然也可以MapXtreme添加多边形面图元
            MapInfo.Geometry.DRect rect = new MapInfo.Geometry.DRect(RectPoint[0,0], RectPoint[0,1], RectPoint[1,0], RectPoint[1, 1]);
            MapInfo.Geometry.CoordSys cs = this.mapControl1.Map.GetDisplayCoordSys();

        //最后是清除临时图层图元
        public void ClearFeature()
        {
            SearchInfo si;
            IResultSetFeatureCollection ifs;
            MapInfo.Data.Table Tm;
            Tm = Cat.GetTable(tmpTableName);
            if (Tm != null) //Table exists close it
            {
                Tm.BeginAccess(TableAccessMode.Write);
                si = MapInfo.Data.SearchInfoFactory.SearchWhere("");
                ifs = MapInfo.Engine.Session.Current.Catalog.Search(tmpTableName, si);
                foreach (Feature ft in ifs)
                    Tm.DeleteFeature(ft);//删除所有该图层上的图元
                Tm.EndAccess();
                //如果只删除某个图元,就不要循环删除了。
            }
        }
 

分享到: 豆瓣 新浪微博 百度贴吧 QQ空间 QQ好友
复制链接分享给好友或者自己收藏!这里会及时更新中。。。

相关推荐:
 
QQ
QQ:278325424
咨询热线
18191066384