一、在ArcMap中的定位操作

已知若干点的经纬度坐标,要求在地图中进行定位:

1.通过Tool 》Add X Y data 定位点,注意选择地理坐标系下的wgs 1984坐标系;

2.定位后的点不能执行查询、分析等操作,需要重新export data;

3.导出的数据最好转换成投影坐标,以便于计算。可首先把已知投影坐标的图层加载到地图中,然后加入第二步产生的点图层,然后将点图层export data,注意坐标系统选择“the data frame”

二、在ArcObject开发时定位的代码示例

2.1 代码参考1

  1. private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
  2. {
  3.  
  4. if (i >= )//测试目的
  5. return;
  6. i++;
  7.  
  8. ITextElement te = createTextElement(e.mapX,e.mapY,"魁x");
  9. axMapControl1.ActiveView.GraphicsContainer.AddElement(te as IElement, );
  10. axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
  11.  
  12. }
  13. int i;
  14.  
  15. public IBalloonCallout createBalloonCallout(double x, double y)
  16. {
  17. IRgbColor rgb = new RgbColorClass();
  18. {
  19. rgb.Red = ;
  20. rgb.Green = ;
  21. rgb.Blue = ;
  22.  
  23. }
  24. ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
  25. {
  26. sfs.Color = rgb;
  27. sfs.Style = esriSimpleFillStyle.esriSFSSolid;
  28. }
  29.  
  30. IPoint p = new PointClass();
  31. {
  32. p.PutCoords(x, y);
  33. }
  34.  
  35. IBalloonCallout bc = new BalloonCalloutClass();
  36. {
  37. bc.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
  38. //
  39. bc.Symbol = sfs;
  40. //
  41. bc.LeaderTolerance = ;
  42. //
  43.  
  44. bc.AnchorPoint = p;
  45. }
  46.  
  47. return bc;
  48. }
  49.  
  50. public ITextElement createTextElement(double x, double y, string text)
  51. {
  52. IBalloonCallout bc = createBalloonCallout(x, y);
  53.  
  54. IRgbColor rgb = new RgbColorClass();
  55. {
  56. //rgb.Red = 255;
  57. rgb.Green = ;
  58. }
  59. ITextSymbol ts = new TextSymbolClass();
  60. {
  61. ts.Color = rgb;
  62. }
  63.  
  64. IFormattedTextSymbol fts = ts as IFormattedTextSymbol;
  65. {
  66. fts.Background = bc as ITextBackground;
  67. }
  68. //fts.Size = 8;
  69. ts.Size = ;
  70.  
  71. IPoint point = new PointClass();
  72. {
  73. double width = axMapControl1.Extent.Width / ;
  74. double height = axMapControl1.Extent.Height / ;
  75. point.PutCoords(x + width, y + height);
  76. }
  77.  
  78. ITextElement te = new TextElementClass();
  79. //IMarkerElement me = new MarkerElementClass();
  80. {
  81. te.Symbol = ts;
  82. //ts.Text = text;
  83. te.Text = text;
  84. }
  85.  
  86. IElement e = te as IElement;
  87. {
  88. e.Geometry = point;
  89. }
  90. return te;
  91.  
  92. }
  93. }

2.2 地图中添加label以标注地图

有多种方法:

1.使用TextElement

2.使用Label属性或与lyr文件或mxd文件结合进行标注

3.使用AnnotateLayerPropertiesCollection对象进行复杂标注

其中,第二种方法的代码为:

  1. private void AddLabel2Map(string strField)
  2. {
  3. IGeoFeatureLayer pGeoFeatureLayer;
  4. ILineLabelPosition pLineLabelPosition;
  5. ILabelEngineLayerProperties pLabelEngineLayerProperties;
  6. IAnnotateLayerProperties pAnnotateLayerProperties;
  7.  
  8. pGeoFeatureLayer = (IGeoFeatureLayer)pMapControl.get_Layer();
  9. pGeoFeatureLayer.AnnotationProperties.Clear();
  10.  
  11. pLineLabelPosition = new LineLabelPositionClass();
  12. pLineLabelPosition.Above = false;
  13. pLineLabelPosition.AtEnd = false;
  14. pLineLabelPosition.Below = false;
  15. pLineLabelPosition.Horizontal = false;
  16. pLineLabelPosition.InLine = true;
  17. pLineLabelPosition.OnTop = true;
  18. pLineLabelPosition.Parallel = true;
  19. pLineLabelPosition.ProduceCurvedLabels = true;
  20.  
  21. pLabelEngineLayerProperties = new LabelEngineLayerPropertiesClass();
  22. pLabelEngineLayerProperties.Symbol = new TextSymbolClass();
  23. pLabelEngineLayerProperties.IsExpressionSimple = true;
  24. pLabelEngineLayerProperties.Expression = "[" + strField + "]";//需要中括号
  25. pLabelEngineLayerProperties.BasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition;
  26.  
  27. pAnnotateLayerProperties = (IAnnotateLayerProperties)pLabelEngineLayerProperties;
  28. pAnnotateLayerProperties.DisplayAnnotation = true;
  29. pAnnotateLayerProperties.FeatureLayer = pGeoFeatureLayer;
  30.  
  31. pAnnotateLayerProperties.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
  32. pAnnotateLayerProperties.WhereClause = "";
  33.  
  34. pGeoFeatureLayer.AnnotationProperties.Add(pAnnotateLayerProperties);
  35. pGeoFeatureLayer.DisplayAnnotation = true;
  36. pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
  37. }

这种方法的一个简化是,在ArcMap中事先设定好图层标记的属性,保存为mxd或lyr文件,程序中只使用

pGeoFeatureLayer.DisplayAnnotation和pGeoFeatureLayer.DisplayField设定显示的字段以及是否显示。

在ArcMap中设定的一些细节为:

1.设定标记是否重复、是否每个图元一个标记、或每个图元的每一部分都有一个标记,如图:

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

还可以设置其他更为丰富的格式。

参考文章

1. 风过 无痕.arcEngine经典代码-添加气泡提示框(标注,文本,). 2008-8.

2. 丛晓男. 在地图中添加label以标注地图. 2010-6.

Arc Engine 中添加气泡提示框的更多相关文章

  1. MFC中添加ToolTip提示框

    PART 1 MFC 对话框中的 Buttton添加提示 例如我们想在一个对话框中的一个button控件添加tooltip,实现的方法如下: 1. 在该对话框的类中添加一个CToolTipCtrl类型 ...

  2. 在vue项目中添加全局提示框

    1.写一个提示框组件:msg.vue (注明:这里用两个div的原因是成功和失败的提示不能用同一个div,因为他们可能紧接着出现,所以不能从始至终只有一个提示框在工作) 2.写一个调用此组建的js : ...

  3. Qt显示Linux desktop natification气泡提示框

    在现代Linux桌面环境上我们时常可以看到类似的消息框: 这些消息框常用在如下场景: 即时聊天软件的新消息 闹钟定时提示 电池电量提示 邮件消息 长耗时操作的完成提示 在freedesktop.org ...

  4. iOS 灵活,简易,扩展性强的气泡提示框LFBubbleView(含源码)

    一.效果图 二.使用方法 使用简单,4行代码集成. _bubbleView = [[LFBubbleView alloc] initWithFrame:CGRectMake(, , , )]; _bu ...

  5. JSP中添加弹出框

    JSP中添加弹出框 %> <script language="javascript" type="text/javascript"> aler ...

  6. 在ASP.NET中引用自定义提示框

    在html网页中自定义提示框 正文: 在一般的B/S架构中项目,与用户的交互信息是非常重要的.在一般的情况下,设计人员都在把用户信息呈现在html中,用div和span去弹出相关信息.对于一般的情况而 ...

  7. ARC工程中添加非ARC文件

    转载自:http://blog.csdn.net/zhenweicao/article/details/16988543 分类: IOS2013-11-27 17:02 626人阅读 评论(0) 收藏 ...

  8. ArcGIS Engine中添加点、线、面元素

    转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...

  9. UWP中的消息提示框(一)

    不管什么平台,应用内难免会出现一些消息提示框,下面就来聊聊我在UWP里用到的消息提示框. 弹窗也可按是否需要用户操作促发一些逻辑进行分为两大类. 不需要用户干涉的一类: MessageDialog:操 ...

随机推荐

  1. Oracle/PLSQL: Creating Functions

    In Oracle, you can create your own functions. 译:在ORACLE中,你可以创建你自己的方法. The syntax for a function is: ...

  2. POJ 3104

    Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7959   Accepted: 2014 Descriptio ...

  3. JavaSE GUI显示列表 JTable的刷新 重新加载新的数据

    JTable在显示所有数据之后,假如需要搜索某个名字,则会获取新的列表数据. 假设datas是JTable的数据,定义为: private Vector<Vector> datas = n ...

  4. Oracle - 位图索引的适用条件

    位图索引的适用条件 位图索引适合只有几个固定值的列,如性别.婚姻状况.行政区等等,而身份证号这种类型不适合用位图索引. 位图索引适合静态数据,而不适合索引频繁更新的列. 举个例子,有这样一个字段bus ...

  5. vector、string实现大数加法乘法

    理解 vector 是一个容器,是一个数据集,里边装了很多个元素.与数组最大的不同是 vector 可以动态增长. 用 vector 实现大数运算的关键是,以 string 的方式读入一个大数,然后将 ...

  6. Project Euler 83:Path sum: four ways 路径和:4个方向

    Path sum: four ways NOTE: This problem is a significantly more challenging version of Problem 81. In ...

  7. lintcode :Binary Tree Preorder Traversal 二叉树的前序遍历

    题目: 二叉树的前序遍历 给出一棵二叉树,返回其节点值的前序遍历. 样例 给出一棵二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [1,2,3]. 挑战 你能使用非递归实现么? 解题: 通过递 ...

  8. C语言的字符测试函数

    C语言的字符测试函数 isalnum, isalpha, isdigit, isxdigit, isblank, isspace, isascii, iscntrl, ispunct, isgraph ...

  9. MVC下基于DotNetOpenAuth 实现SSO单点登录

    具体官网可以查看:http://dotnetopenauth.net/,托管地址:https://github.com/DotNetOpenAuth/DotNetOpenAuth 可能需要FQ 博客园 ...

  10. Swift 版本很好的卡片切换效果基于ZLSwipeableView

    前言:在这篇文章你可以学到,一些基本的Swift语法, 基本UI控件闭包等. 实际的效果,比gif图的效果好很多. 卡片切换.gif 首先需要导入ZLSwipeableView pod 'ZLSwip ...