MapLayerEnumerator mle = mapControl1.Map.Layers.GetMapLayerEnumerator(iml);
mapControl1.Map.SetView(mle);
10.//创建临时层
TableInfoMemTable tblInfoTemp = new TableInfoMemTable("Animation");
MapInfo.Data.Table tblTemp = cat.GetTable("Animation");
if (tblTemp != null) //Table exists close it
{
cat.CloseTable("Animation");
}
tblInfoTemp.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(MapControl1.Map.GetDisplayCoordSys()));
tblInfoTemp.Columns.Add(ColumnFactory.CreateStyleColumn());
tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("NAME", 40));
tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Dept", 15));
tblInfoTemp.Columns.Add(ColumnFactory.CreateIntColumn("Level")); //TableInfoMemTable是TableInfo类继承来的
tblTemp = cat.CreateTable(tblInfoTemp);
FeatureLayer lyr = new FeatureLayer(tblTemp);
MapControl1.Map.Layers.Add(lyr);
Mapx中基本的图层操作还是比较简单的,集中在对Layers和Layer的处理上,对别的没有太多要求。
在MapXtreme中,要完成类似功能,发生了一点变化,如下:
1、图层的显示
在MapXtreme中,图层的显示控制发生了奇怪的变化,有一个IsVisible属性,但它是只读的,不能通过它来改变图层的显示。要控制图层的显示与隐藏,可以通过设置Layer.Enable来控制。
2、图层的动态添加
代码如下:
Catalog _catalog=MapInfo.Engine.Session.Current.Catalog;
MapInfo.Data.Table _tempTable=null;
Map _map=MapControl1.Map ;
TableInfo ti = TableInfoFactory.CreateTemp("临时");
_tempTable = _catalog.CreateTable(ti);
_map.Layers.Insert(0, new FeatureLayer(_tempTable));
可以看出:加图层实际就是加表;Catalog对象统管表的加载以及列举;
查帮助还可以了解:表信息其实还可以包括表的类型和坐标系。类型是指原生表,文本,access ...
上面的ti也可以这样取得,但是,上面的表默认是MeMTab,应该是内存中的吧。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-27883-6.html
这年头
甲午海战前
裹挟人类的良知