MapXtreme 2005学习(1):创建临时图层

来源:互联网 发布:java基础框架 编辑:程序博客网 时间:2024/05/16 15:18
      首先说明一下创建临时图层的作用,当你需要在现有的地图上动态地添加一些点或线等图元时,就可以在临时

图层中进行。比如说在作动态轨迹跟踪时,通过读取数据库中的点坐标,不断地更新轨迹和图元的位置。代码如

下:

 

    /// <summary>
    /// 创建临时图层
    /// Design by Glacier
    /// 2008年8月6日
    /// <param name="tempLayerTableName">表名</param>
    /// <param name="tempLayerName">图层名</param>
    /// </summary>
    public static void CreateTempLayer(string tempLayerTableName, string tempLayerName)
    {
        MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory

[MapControl1.MapAlias];

        //指定表名建立表信息
        MapInfo.Data.TableInfoMemTable tblInfoTemp = new MapInfo.Data.TableInfoMemTable

(tempLayerTableName);

        //确保当前目录下不存在同名表
        MapInfo.Data.Table tblTemp = MapInfo.Engine.Session.Current.Catalog.GetTable

(tempLayerTableName);
        if (tblTemp != null)
        {
            MapInfo.Engine.Session.Current.Catalog.CloseTable(tempLayerTableName);
        }

        //向表信息中添加可绘图列
        tblInfoTemp.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn

(myMap.GetDisplayCoordSys()));
        tblInfoTemp.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());

        //向表信息中添加自定义列
        tblInfoTemp.Columns.Add(MapInfo.Data.ColumnFactory.CreateIntColumn("index"));
        tblInfoTemp.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn("name", 10));

        //根据表信息创建临时表
        tblTemp = MapInfo.Engine.Session.Current.Catalog.CreateTable(tblInfoTemp);

        //指定表,图层名和图层别名创建临时图层
        FeatureLayer tempLayer = new FeatureLayer(tblTemp, tempLayerName, tempLayerName);
        myMap.Layers.Add(tempLayer);
    }

 

引用自http://www.cnblogs.com/glacierh/archive/2008/08/06/1261824.html

 

 

http://www.cnblogs.com/glacierh/category/148898.html

 

http://hi.baidu.com/donghaibo010/blog/category/Mapxtreme

 

 

原创粉丝点击