创建临时图层-添加图元-加图层标注-清除图元
2014-05-23 15:34
417 查看
[转]MapXtreme 图层操作 创建临时图层-添加图元-加图层标注-清除图元
2011-11-22阅读162 评论0操作实体类:
public class map_operation
{
public MapControlModel model;
public MapInfo.Mapping.Map map;
public Catalog Cat;
public MapInfo.Data.Table tblTemp;
public map_operation()
{
model = MapControlModel.GetModelFromSession();
map = model.GetMapObj("Map1");
Cat = MapInfo.Engine.Session.Current.Catalog;
tblTemp = Cat.GetTable("Animation");
}
//创建临时图层
public void creat_temp_table()
{
TableInfoMemTable tblInfoTemp = new TableInfoMemTable("Animation"); //创建GPS终端小车集图层
if (tblTemp != null) //Table exists close it
{
Cat.CloseTable("Animation");
}
tblInfoTemp.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(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);
map.Layers.Add(lyr);
}
//添加图元
public void insert_feature(string fileName,double x,double y,string GPS_NUMBER)
{
BitmapPointStyle bStyle = new BitmapPointStyle(fileName); //fileName格式为@"gpscar2_p2.bmp" 这个@代表C:\Program Files\Common Files\MapInfo\MapXtreme\6.7.1\CustSymb
bStyle.PointSize = Convert.ToInt16(24);
bStyle.NativeSize = true;
bStyle.Attributes = StyleAttributes.PointAttributes.BaseAll;
bStyle.SetApplyAll();
FeatureGeometry pt = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), new DPoint(y, x)) as FeatureGeometry;
Feature ftr = new Feature(tblTemp.TableInfo.Columns);
ftr.Geometry = pt; //图元地理位置设置
ftr.Style = bStyle; //图元为位图样式
ftr["Name"] = "aaaa";
ftr["Dept"] = GPS_NUMBER; //GPS终端号
ftr["Level"] = 2;
tblTemp.InsertFeature(ftr); //插入图元
}
//加图层标注
public void creat_mark()
{
MapInfo.Data.Table tblTemp = Cat.GetTable("Animation");
LabelSource labelSource = new LabelSource(tblTemp); //给所创建的临时表Animation中的图元加标注
//指定要标准字段所在的列
labelSource.DefaultLabelProperties.Caption = "Name"; //所要标注的列名
labelSource.DefaultLabelProperties.Layout.Offset = 8; //标注偏移
labelSource.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.TopRight;//标注对齐方式
labelSource.DefaultLabelProperties.Style.Font.BackColor = System.Drawing.Color.White; //字体背景
labelSource.DefaultLabelProperties.Style.Font.ForeColor = System.Drawing.Color.Red; //字体颜色
labelSource.DefaultLabelProperties.Style.Font.TextEffect = MapInfo.Styles.TextEffect.Box; //边缘效果
labelSource.DefaultLabelProperties.Style.Font.FontWeight = MapInfo.Styles.FontWeight.Bold; //粗体
MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(0); //标注注释线
labelSource.DefaultLabelProperties.Style.CalloutLine.ApplyStyle(simpleLineStyle);
//取消标注注释线
LabelLayer labelLayer = new LabelLayer();
labelLayer.Name = "jcbz"; //设置标注图层的名称
labelLayer.Sources.Append(labelSource); //往地图中加入该标注层
map.Layers.Add(labelLayer);
}
//清除临时图层中所有的图元
public void clear_feature()
{
SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("");
IResultSetFeatureCollection ifs;
MapInfo.Data.Table Tm;
Tm = Cat.GetTable("Tm");
if (Tm != null) //Table exists close it
{
si = MapInfo.Data.SearchInfoFactory.SearchWhere("");
ifs = MapInfo.Engine.Session.Current.Catalog.Search("Tm", si);
foreach (Feature ft in ifs)
Tm.DeleteFeature(ft); //删除所有该图层上的图元
}
}
}
相关文章推荐
- MapXtreme 图层操作 创建临时图层-添加图元-加图层标注-清除图元
- QGis C++ 开发之创建临时图层并添加要素
- MapXtreme 2005学习(1):创建临时图层
- MapXtreme 2005学习(1):创建临时图层
- 在Delphi下基于MapWinGIS添加和删除图层标注的方法
- arcgis api for javascript 添加图层时设置标注,自定义符号
- 创建百度地图,设置地图缩放,设置标注,添加信息窗口
- 自动创建临时表,并给临时表添加一个自动增长的行号字段
- 创建点实体图层--向量图层,为什么在图层管理器中没有添加点、线、面的按钮?
- MapX中使用动态图层AnimationLayer,移动图元时标注和图元分离问题解决办法。
- VC+MapX 在临时图层中添加点图元
- 添加标注图层
- 创建临时图层
- 不在可视区域,重新创建地图,添加标注
- 修改某图层内容使其立即反映到地图上(添加、删除图元)
- MapXtreme 2005学习(4):添加标注图层
- MapGuide 添加临时点图层
- 创建临时图层
- delphi mapX添加图层,在图层上画图元,并给图元添加位图
- 地图(创建, 添加图块, 图层, 对象层,添加图块属性调整修改地图)