向图层中添加点
在添加点之前先要在地图上创建一个临时图层,创建临时图层请参考《MapXtreme2005学习(1):创建临时图层》。本示例中通过指定图层名,表名,点坐标在图层中添加一个点。代码如下: 复制内容到剪贴板 代码: /// /// 向图层中添加点 /// 2008年8月6日 /// 表名 /// 图层名 /// 点坐标 /// public static void AddPointToLayer(string tempLayerTableName, string tempLayerName, DPoint dPoint) { MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]; //获取图层和表 FeatureLayer workLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[tempLayerName]; MapInfo.Data.Table tblTemp = MapInfo.Engine.Session.Current.Catalog.GetTable(tempLayerTableName); //创建点图元及其样式 FeatureGeometry pgPoint = new MapInfo.Geometry.Point(workLayer.CoordSys, dPoint); MapInfo.Styles.SimpleVectorPointStyle spsPoint = new MapInfo.Styles.SimpleVectorPointStyle(37, System.Drawing.Color.Red, 20); MapInfo.Styles.CompositeStyle csPoint = new MapInfo.Styles.CompositeStyle(spsPoint); MapInfo.Data.Feature ptPoint = new MapInfo.Data.Feature(tblTemp.TableInfo.Columns); ptPoint.Geometry = pgPoint; ptPoint.Style = csPoint; //将点图元加入图层 workLayer.Table.InsertFeature(ptPoint); }