转: C#+MAPX 添加线、文本、符号等图元

转: C#+MAPX 添加线、文本、符号等图元

1.添加线段MapXLib.Layer lyr;MapXLib.CoordSys coor = axMap1.DisplayCoordSys;//坐标lyr = axMap1.Layers.CreateLayer("temp_start", Type.Missing, 100, 10, coor);axMap1.Layers.AnimationLayer = lyr;//新建一个临时图层lyr.Editable = true;lyr.Visible = true; MapXLib.Point start = new MapXLib.PointClass();//新建起点MapXLib.Point end = new MapXLib.PointClass();//新建终点start.Set(node1.X, node1.Y);end.Set(node2.X, node2.Y); MapxLib.Feature LineObg;MapXLib.Points pts=new MapXlib.PointClass();MapXLib.Feature LineObj;MapXLib.Points pts = new MapXLib.PointsClass();pts.Add(start, 1);pts.Add(end, 2); LineObj = axMap1.FeatureFactory.CreateLine(pts, axMap1.DefaultStyle);lyr.AddFeature(LineObj, Type.Missing); 2.添加文本MapXLib.Layer lyr;lyr = axMap1.Layers.CreateLayer("temp_start", Type.Missing, 100, 10, coor);axMap1.Layers.AnimationLayer = lyr;//新建一个临时图层lyr.Editable = true;lyr.Visible = true; MapXLib.Style mystyle = new StyleClass();//文本格式mystyle.TextFont.Bold = false;mystyle.TextFont.Size = 0.1m;mystyle.TextFontColor = 0x0000FF; MapXLib.Feature TextObj;TextObj = axMap1.FeatureFactory.CreateText(middle, EdgeID.ToString(), Type.Missing, mystyle);//第一个参数为Point lyr.AddFeature(TextObj, Type.Missing); 3.添加符号MapXLib.Layer tempstar_lyr;MapXLib.CoordSys coor = axMap1.DisplayCoordSys;tempstar_lyr = axMap1.Layers.CreateLayer("temp_start", Type.Missing, 100, 10, coor);tempstar_lyr.Editable = true;tempstar_lyr.Visible = true;tempstar_lyr.AutoLabel = true;tempstar_lyr.OverrideStyle = true;tempstar_lyr.Style.SymbolFontColor = 0x0000FF;tempstar_lyr.Style.SymbolType = MapXLib.SymbolTypeConstants.miSymbolTypeVector;//选择符号样式tempstar_lyr.Style.SymbolVectorSize = 20; MapXLib.Feature SymbolObj=new FeatureClass();SymbolObj.Attach(axMap1.GetOcx());SymbolObj.KeyValue = "S";SymbolObj.Point = pt;tempstar_lyr.AddFeature(SymbolObj, Type.Missing);
posted @ 2012-10-18 17:32  海燕一家  阅读(436)  评论(0编辑  收藏  举报