您的位置:首页 > 其它

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

2010-04-28 09:17 260 查看
首先说明一下创建临时图层的作用,当你需要在现有的地图上动态地添加一些点或线等图元时,就可以在临时
图层中进行。比如说在作动态轨迹跟踪时,通过读取数据库中的点坐标,不断地更新轨迹和图元的位置。代码如

下:

/// <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);
}

引用自/article/6008007.html

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

http://hi.baidu.com/donghaibo010/blog/category/Mapxtreme
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: