catalog Cat = MapInfo.Engine.Session.Current.Catalog;
//创建临时层
TableInfoMemTable tblInfoTemp = new TableInfoMemTable("Animation");
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"));tblTemp = Cat.CreateTable(tblInfoTemp);
FeatureLayer lyr = new FeatureLayer(tblTemp);
mapControl1.Map.Layers.Add(lyr);//创建点
FeatureGeometry pt = new MapInfo.Geometry.Point(lyr.CoordSys, new DPoint(-76, 42)) as FeatureGeometry;
CompositeStyle cs = new CompositeStyle(new SimpleVectorPointStyle(37, System.Drawing.Color.Red, 10));
Feature ftr = new Feature(tblTemp.TableInfo.Columns);
ftr.Geometry = pt;
ftr.Style = cs;
ftr["Name"] = "Kelly";
ftr["Dept"] = "Sales";
ftr["Level"] = 3;
tblTemp.InsertFeature(ftr);FeatureGeometry pt2 = new MapInfo.Geometry.Point(lyr.CoordSys, new DPoint(-119, 34)) as FeatureGeometry;
CompositeStyle cs2 = new CompositeStyle(new SimpleVectorPointStyle(44, System.Drawing.Color.Purple, 10));
Feature ftr2 = new Feature(tblTemp.TableInfo.Columns);
ftr2.Geometry = pt2;
ftr2.Style = cs2;
ftr2["Name"] = "Greg";
ftr2["Dept"] = "Marketing";
ftr2["Level"] = 2;
tblTemp.InsertFeature(ftr2);//********************************************************
//另外一种增加小车的方法:
//创建小车及其样式
Connection=new MapInfo.Data.MIConnection();
Connection.Open ();
MapInfo.Geometry.Point pt=new MapInfo.Geometry.Point(mapControl1.Map.GetDisplayCoordSys(),-122.8788,40.3815);
MapInfo.Styles.FontPointStyle sty=new MapInfo.Styles.FontPointStyle(66,new MapInfo.Styles.Font("MapInfo Transportation",48),0,System.Drawing.Color.Aqua,18);
//将小车增加到图层
MICommand comm=Connection.CreateCommand();
comm.CommandText ="Insert into targetTable(ID,name,obj,mi_style) values('1','car1',@obj,@style)";
comm.Parameters.Add ("@obj",pt);
comm.Parameters.Add ("@style",sty);
comm.ExecuteNonQuery();Connection.Close();
在MapXtreme2004地图中建一个显示小车的图层
最新推荐文章于 2021-02-21 06:24:27 发布
这篇博客介绍了如何在MapXtreme2004中建立一个显示小车的图层,通过创建临时表和特征层,设置点几何和样式,展示了两种添加小车到地图的方法,包括使用CompositeStyle和插入带有样式的对象到图层。
摘要由CSDN通过智能技术生成