创建临时图层-添加图元-加图层标注-清除图元
来源:互联网 发布:linux下安装vim 编辑:程序博客网 时间:2024/05/14 08:50
[转]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 图层操作 创建临时图层-添加图元-加图层标注-清除图元
- 创建临时图层-添加图元-加图层标注-清除图元
- 添加标注图层
- 创建临时图层
- mapxtreme 添加图元
- MapX中使用动态图层AnimationLayer,移动图元时标注和图元分离问题解决办法。
- C#MapX添加图元
- 在Mapxtreme中修改单个图元的标注
- 在Mapxtreme中修改单个图元的标注
- 图元和图层搜索
- ArcGISMobile+WM6环境下,FeatureLayer图层的图元添加和删除操作
- D3D创建基本图元函数解析
- osg创建简单图元(2)
- 按照比例尺标注图层
- 普元 EOS Platform 7.6 webservice图元添加自定义Header
- MapXtreme 2005学习(1):创建临时图层
- MapXtreme 2005学习(1):创建临时图层
- 识别图元(Queue)
- Hibernate关联关系配置-----基于连接表的双向多对多配置
- oracle导入导出脚本的有关问题
- vsftp上传的550错误
- Oracle XMLTable 使用教程与实例
- R语言之数据挖掘篇
- 创建临时图层-添加图元-加图层标注-清除图元
- 程序测试C程序内存空间布局
- Apache Thrift 介绍
- Sqlite数据库的升级及之前数据的保留
- LCD调试总结
- CharacterEncodingFilter
- android 拍照上传照片
- ALSA音频库的移植 ARM 交叉编译 环境变量
- 开个刷题的分类