zoukankan      html  css  js  c++  java
  • MapXtreme 2005学习(1):创建临时图层

          首先说明一下创建临时图层的作用,当你需要在现有的地图上动态地添加一些点或线等图元时,就可以在临时

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

    下:

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

  • 相关阅读:
    机器人对话小程序
    partial关键字的含义
    TreeView控件常用写法
    电话本管理程序(实现增删改查功能)
    三层架构
    c# RegistryKey 的相关简单操作
    VS2010程序打包操作(超详细的)
    一些中文.net讲座
    对象表单自动数据邦定
    AspNetForums 2.0中的全文检索
  • 原文地址:https://www.cnblogs.com/glacierh/p/1261824.html
Copyright © 2011-2022 走看看