Arc Engine 中添加气泡提示框
一、在ArcMap中的定位操作
已知若干点的经纬度坐标,要求在地图中进行定位:
1.通过Tool 》Add X Y data 定位点,注意选择地理坐标系下的wgs 1984坐标系;
2.定位后的点不能执行查询、分析等操作,需要重新export data;
3.导出的数据最好转换成投影坐标,以便于计算。可首先把已知投影坐标的图层加载到地图中,然后加入第二步产生的点图层,然后将点图层export data,注意坐标系统选择“the data frame”
二、在ArcObject开发时定位的代码示例
2.1 代码参考1
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{ if (i >= )//测试目的
return;
i++; ITextElement te = createTextElement(e.mapX,e.mapY,"魁x");
axMapControl1.ActiveView.GraphicsContainer.AddElement(te as IElement, );
axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); }
int i; public IBalloonCallout createBalloonCallout(double x, double y)
{
IRgbColor rgb = new RgbColorClass();
{
rgb.Red = ;
rgb.Green = ;
rgb.Blue = ; }
ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
{
sfs.Color = rgb;
sfs.Style = esriSimpleFillStyle.esriSFSSolid;
} IPoint p = new PointClass();
{
p.PutCoords(x, y);
} IBalloonCallout bc = new BalloonCalloutClass();
{
bc.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
//
bc.Symbol = sfs;
//
bc.LeaderTolerance = ;
// bc.AnchorPoint = p;
} return bc;
} public ITextElement createTextElement(double x, double y, string text)
{
IBalloonCallout bc = createBalloonCallout(x, y); IRgbColor rgb = new RgbColorClass();
{
//rgb.Red = 255;
rgb.Green = ;
}
ITextSymbol ts = new TextSymbolClass();
{
ts.Color = rgb;
} IFormattedTextSymbol fts = ts as IFormattedTextSymbol;
{
fts.Background = bc as ITextBackground;
}
//fts.Size = 8;
ts.Size = ; IPoint point = new PointClass();
{
double width = axMapControl1.Extent.Width / ;
double height = axMapControl1.Extent.Height / ;
point.PutCoords(x + width, y + height);
} ITextElement te = new TextElementClass();
//IMarkerElement me = new MarkerElementClass();
{
te.Symbol = ts;
//ts.Text = text;
te.Text = text;
} IElement e = te as IElement;
{
e.Geometry = point;
}
return te; }
}
2.2 地图中添加label以标注地图
有多种方法:
1.使用TextElement
2.使用Label属性或与lyr文件或mxd文件结合进行标注
3.使用AnnotateLayerPropertiesCollection对象进行复杂标注
其中,第二种方法的代码为:
private void AddLabel2Map(string strField)
{
IGeoFeatureLayer pGeoFeatureLayer;
ILineLabelPosition pLineLabelPosition;
ILabelEngineLayerProperties pLabelEngineLayerProperties;
IAnnotateLayerProperties pAnnotateLayerProperties; pGeoFeatureLayer = (IGeoFeatureLayer)pMapControl.get_Layer();
pGeoFeatureLayer.AnnotationProperties.Clear(); pLineLabelPosition = new LineLabelPositionClass();
pLineLabelPosition.Above = false;
pLineLabelPosition.AtEnd = false;
pLineLabelPosition.Below = false;
pLineLabelPosition.Horizontal = false;
pLineLabelPosition.InLine = true;
pLineLabelPosition.OnTop = true;
pLineLabelPosition.Parallel = true;
pLineLabelPosition.ProduceCurvedLabels = true; pLabelEngineLayerProperties = new LabelEngineLayerPropertiesClass();
pLabelEngineLayerProperties.Symbol = new TextSymbolClass();
pLabelEngineLayerProperties.IsExpressionSimple = true;
pLabelEngineLayerProperties.Expression = "[" + strField + "]";//需要中括号
pLabelEngineLayerProperties.BasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition; pAnnotateLayerProperties = (IAnnotateLayerProperties)pLabelEngineLayerProperties;
pAnnotateLayerProperties.DisplayAnnotation = true;
pAnnotateLayerProperties.FeatureLayer = pGeoFeatureLayer; pAnnotateLayerProperties.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
pAnnotateLayerProperties.WhereClause = ""; pGeoFeatureLayer.AnnotationProperties.Add(pAnnotateLayerProperties);
pGeoFeatureLayer.DisplayAnnotation = true;
pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
这种方法的一个简化是,在ArcMap中事先设定好图层标记的属性,保存为mxd或lyr文件,程序中只使用
pGeoFeatureLayer.DisplayAnnotation和pGeoFeatureLayer.DisplayField设定显示的字段以及是否显示。
在ArcMap中设定的一些细节为:
1.设定标记是否重复、是否每个图元一个标记、或每个图元的每一部分都有一个标记,如图:

2.如何设定label只保留两位小数,如图:

还可以设置其他更为丰富的格式。
参考文章
1. 风过 无痕.arcEngine经典代码-添加气泡提示框(标注,文本,). 2008-8.
2. 丛晓男. 在地图中添加label以标注地图. 2010-6.
Arc Engine 中添加气泡提示框的更多相关文章
- MFC中添加ToolTip提示框
PART 1 MFC 对话框中的 Buttton添加提示 例如我们想在一个对话框中的一个button控件添加tooltip,实现的方法如下: 1. 在该对话框的类中添加一个CToolTipCtrl类型 ...
- 在vue项目中添加全局提示框
1.写一个提示框组件:msg.vue (注明:这里用两个div的原因是成功和失败的提示不能用同一个div,因为他们可能紧接着出现,所以不能从始至终只有一个提示框在工作) 2.写一个调用此组建的js : ...
- Qt显示Linux desktop natification气泡提示框
在现代Linux桌面环境上我们时常可以看到类似的消息框: 这些消息框常用在如下场景: 即时聊天软件的新消息 闹钟定时提示 电池电量提示 邮件消息 长耗时操作的完成提示 在freedesktop.org ...
- iOS 灵活,简易,扩展性强的气泡提示框LFBubbleView(含源码)
一.效果图 二.使用方法 使用简单,4行代码集成. _bubbleView = [[LFBubbleView alloc] initWithFrame:CGRectMake(, , , )]; _bu ...
- JSP中添加弹出框
JSP中添加弹出框 %> <script language="javascript" type="text/javascript"> aler ...
- 在ASP.NET中引用自定义提示框
在html网页中自定义提示框 正文: 在一般的B/S架构中项目,与用户的交互信息是非常重要的.在一般的情况下,设计人员都在把用户信息呈现在html中,用div和span去弹出相关信息.对于一般的情况而 ...
- ARC工程中添加非ARC文件
转载自:http://blog.csdn.net/zhenweicao/article/details/16988543 分类: IOS2013-11-27 17:02 626人阅读 评论(0) 收藏 ...
- ArcGIS Engine中添加点、线、面元素
转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...
- UWP中的消息提示框(一)
不管什么平台,应用内难免会出现一些消息提示框,下面就来聊聊我在UWP里用到的消息提示框. 弹窗也可按是否需要用户操作促发一些逻辑进行分为两大类. 不需要用户干涉的一类: MessageDialog:操 ...
随机推荐
- POJ 3273
Monthly Expense Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12122 Accepted: 4932 ...
- 提交jar作业到spark上运行
1.引入spark包:spark-assembly-1.4.0-hadoop2.6.0,在spark的lib目录下 File-->project structure 2.用IDEA建立一个sca ...
- 关于ios 8 7 下的模态窗口大小的控制 代碼+場景(mainstoryboard)( Resizing UIModalPresentationFormSheet )
1 代碼 UIViewController* modalController = [[UIViewController alloc]init];modalController.modalTransit ...
- hdu1102
http://acm.hdu.edu.cn/showproblem.php?pid=1102 最小生成树(模板题) 3 0 990 692 990 0 179 692 179 0 1 1 2 一共3个 ...
- cognos8.3 sample在DB2里的安装
db2 create db c83 alias c83 using codeset UTF-8 territory CA 创建sample数据库 db2set db2codepage= db2 cha ...
- 可持久化trie 学习总结
QAQ 以前一直觉得可持久化trie很难,今天强行写了一发觉得还是蛮简单的嘛 自己的模板是自己手写的,写了几道题目并没有出过错误 THUSC的第二题的解法五貌似就是可持久化trie,时间复杂度O(60 ...
- 李洪强iOS开之【零基础学习iOS开发】【02-C语言】04-常量、变量
在我们使用计算机的过程中,会接触到各种各样的数据,有文档数据.图片数据.视频数据,还有聊QQ时产生的文字数据.用迅雷下载的文件数据等.这讲我们就来介绍C语言中数据的处理. 一.数据的存储 1.数据类型 ...
- ibatis框架的sqlmapclient接口
SqlMapClient,是iBatis中的重要接口,这个接口涉及到对SQL映射的执行和批处理. 现在,就先了解它的对query开头方法的定义. 首先是 queryForList 方法: //指定SQ ...
- SDK 与MFC
SDK 就是Software Development Kit 软件开发包MFC 就是Microsoft Foundation Classes 微软函数类库.是以C++类的形式封装了Windows的AP ...
- 给360的六条建议(禁止异地登录,普通用户500G足够用了)
个人觉得,360云盘哪怕做个小改进,都不至于走到现在的地步,最后六条建议! 1.弄个实名制,身份证和手机号码双重绑定,每人限制申请一个账户. 2.禁止云盘的一切分享功能,采用封闭式,个人云盘资料其他人 ...