当前位置:编程学习 > C#/ASP.NET >>

使用C#开发MapXtreme项目,如何设置标绘的图元可见和不可见?

使用C#开发MapXtreme项目,创建新的图层,并在新图层上标绘点、直线、圆周等基本几何图形,那如何控制已经标绘在新图层上的几何图形的显示与不显示呢?
以下是标绘点和线的代码:
(1)向图层中添加点

/// <param name="tempLayerTableName">表名</param>
/// <param name="tempLayerName">图层名</param>
/// <param name="dPoint">点坐标</param>
 public void AddPointToLayer(string tempLayerTableName, string tempLayerName, DPoint dPoint)
        {
            MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[ControlMap.Map.Alias];
            //获取图层和表
            FeatureLayer workLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[tempLayerName];
            MapInfo.Data.Table tblTemp = MapInfo.Engine.Session.Current.Catalog.GetTable(tempLayerTableName);
            //创建点图元及其样式
            FeatureGeometry pgPoint = new MapInfo.Geometry.Point(workLayer.CoordSys, dPoint);
            MapInfo.Styles.SimpleVectorPointStyle spsPoint = new MapInfo.Styles.SimpleVectorPointStyle(37, System.Drawing.Color.Red, 20);
            MapInfo.Styles.CompositeStyle csPoint = new MapInfo.Styles.CompositeStyle(spsPoint);
            MapInfo.Data.Feature ptPoint = new MapInfo.Data.Feature(tblTemp.TableInfo.Columns);
            ptPoint.Geometry = pgPoint;
            ptPoint.Style = csPoint;
            ptPoint["index"] = 1;
            ptPoint["name"] = "PointName";
            //将点图元加入图层
            workLayer.Table.InsertFeature(ptPoint);
        }

(2)向图层中添加线段
 
/// <param name="tempLayerTableName">表名</param>
/// <param name="tempLayerName">图层名</param>
/// <param name="startPoint">线段起点坐标</param>
/// <param name="endPoint">线段终点坐标</param>
public void AddLineToLayer(string tempLayerTableName, string tempLayerName, DPoint startPoint, DPoint endPoint)
        {
                MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[ControlMap.Map.Alias];
                //获取图层和表
                FeatureLayer workLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[tempLayerName];
                MapInfo.Data.Table tblTemp = MapInfo.Engine.Session.Current.Catalog.GetTable(tempLayerTableName);
                //创建线图元及其样式
                FeatureGeometry pgLine = MultiCurve.CreateLine(workLayer.CoordSys, startPoint, endPoint);
                MapInfo.Styles.SimpleLineStyle slsLine = new MapInfo.Styles.SimpleLineStyle(new LineWidth(3, LineWidthUnit.Pixel), 2, System.Drawing.Color.OrangeRed);
                MapInfo.Styles.CompositeStyle csLine = new MapInfo.Styles.CompositeStyle(slsLine);
                MapInfo.Data.Feature ptLine = new MapInfo.Data.Feature(tblTemp.TableInfo.Columns);
                ptLine.Geometry = pgLine;
                ptLine.Style = csLine;
                ptLine["index"] = 2;
                ptLine["name"] = "LineName";
                //将线图元加入图层
                workLayer.Table.InsertFeature(ptLine);
        }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,