arcgis气泡标注箭头设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了arcgis气泡标注箭头设置相关的知识,希望对你有一定的参考价值。

ArcGISengine中⽓泡标注的添加、修改!

ArcGIS engine中⽓泡标注,是我们在编辑图形中⼀个重要的⼯具,能提供注释功能,下⾯的介绍怎么来编程实现callout的添加,以及怎么去修改它们!

// 在Mapcontrol的mouseDown中添加下列内容,来添加⽓泡注释功能:callout.

privatevoid axMapControl1_OnMouseDown(object sender,IMapControlEvents2_OnMouseDownEvent e)



axMapControl1.CurrentTool = null;

IPoint pPoint ;

pPoint = new PointClass();

pPoint.PutCoords(e.mapX, e.mapY);

IFormattedTextSymbol pTextSymbol = newTextSymbolClass();

pTextSymbol.Background =CreateBalloonCallout(e.mapX, e.mapY) asITextBackground;

pTextSymbol.Direction =esriTextDirection.esriTDAngle;

pTextSymbol.Angle = 15;

ITextElement pTextElement = newTextElementClass();

pTextElement.Symbol = pTextSymbol asITextSymbol;

pTextElement.Text = "MaDeSheng";

IElement ptexte = pTextElement asIElement;

pPoint = new PointClass();

pPoint.PutCoords(e.mapX * 0.90, e.mapY*1.1);

ptexte.Geometry = pPoint as IGeometry;

IMap pMap = axMapControl1.Map;

IGraphicsContainer pGraphicsContainer = pMap asIGraphicsContainer;

pGraphicsContainer.AddElement(pTextElement asIElement, 0);

this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null, null);



红颜⾊的部分是产⽣⽓泡背景,具体程序如下:

public IBalloonCalloutCreateBalloonCallout(double x, double y)



IRgbColor pRgbClr = newRgbColorClass();

pRgbClr.Red =225;

pRgbClr.Blue =225;

pRgbClr.Green =225;

ISimpleFillSymbol pSmplFill =new SimpleFillSymbolClass();

pSmplFill.Color =pRgbClr;

pSmplFill.Style =esriSimpleFillStyle.esriSFSSolid;

IBalloonCallout pBllnCallout= new BalloonCalloutClass();

//pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRectangle;

pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRoundedRectangle;

pBllnCallout.Symbol =pSmplFill;

pBllnCallout.LeaderTolerance= 5;

IPoint pPoint = newESRI.ArcGIS.Geometry.PointClass();

pPoint.X =x;

pPoint.Y =y;

pBllnCallout.AnchorPoint =pPoint;

returnpBllnCallout;



那么添加了之后如何修改呢?

双击事件!

private void axMapControl1_OnDoubleClick(objectsender, IMapControlEvents2_OnDoubleClickEvent e)



if(e.button ==1)



//标注的修改

if(((axMapControl1.CurrentTool) as ICommand).Name =="ControlToolsGraphicEleme nt_SelectTool")//这⼀句的判断很⽜B,我当时考虑了半天才搞出来。难点呀!toolbarControl中要加载esriControls.ControlsSelectTool⼯具



IPoint pPoint = new PointClass();

pPoint.PutCoords(e.mapX, e.mapY);

IMap pMap = axMapControl1.Map;

IGraphicsContainer pGraphicsContainer = pMap asIGraphicsContainer;

IEnumElement pEnumElement =pGraphicsContainer.LocateElements(pPoint, 10);

if (pEnumElement != null)



IElementpElement = pEnumElement.Next();

if(pElement is ITextElement)



ITextElement ptextElement =pElement as ITextElement;

labelEditCallout pLabelEditCallout = newlabelEditCallout(ptextElement.Text,ptextElement.Symbol);

pLabelEditCallout.ShowDialog();

ptextElement.Text =pLabelEditCallout.inputText;

ptextElement.Symbol =pLabelEditCallout.textSymbol;

pGraphicsContainer.DeleteElement(pElement);

pGraphicsContainer.AddElement(pElement,0);

//这两句可以⽤pGraphicsContainer.UpdataElement(pElement);来代替

this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null, null);











labelEditCallout是我⾃⼰弄的⼀个修改样式,其实很简单的⼀个页⾯,截图如下:

具体,代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

usingESRI.ArcGIS.Display;

usingESRI.ArcGIS.Geometry;

namespaceEdit



public partial class labelEditCallout :Form



publicstring inputText = "";

publicITextSymbol textSymbol;

privatebool ModifFillColor = false;

publiclabelEditCallout(string s,ITextSymbol texSy)



inputText =s;

textSymbol =texSy;

InitializeComponent();



privatevoid labelEditCallout_Load(object sender, EventArgse)



textBox1.Text =inputText;

comboBox1.Items.Add("矩形框");

comboBox1.Items.Add("圆⾓矩形");

//comboBox1.Items.Add("Oval");

comboBox1.SelectedIndex = 1;



publicIColor ConvertColorToIColor(Color color)



IColor pColor = newRgbColorClass();

pColor.RGB = color.B * 65536+ color.G * 256 + color.R;

returnpColor;



privatevoid button2_Click(object sender, EventArgs e)



IBalloonCallout textBack =(((IFormattedTextSymbol)textSymbol).Background) asIBalloonCallout; IFillSymbol pOldFill =textBack.Symbol;

IPoint pPoint =textBack.AnchorPoint;

ISimpleFillSymbol pSmplFill =new SimpleFillSymbolClass();

pSmplFill.Style =esriSimpleFillStyle.esriSFSSolid;

if(ModifFillColor)



pSmplFill.Color =ConvertColorToIColor(this.button1.BackColor);



else

pSmplFill.Color =pOldFill.Color;

IBalloonCallout pBllnCallout= new BalloonCalloutClass();

switch(comboBox1.Text)



case"矩形框":

pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRectangle;

break;

case"圆⾓矩形":

pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRoundedRectangle;

break;

//case"Oval":

// pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSOval;

// break;



pBllnCallout.Symbol =pSmplFill;

pBllnCallout.LeaderTolerance= 5;

pBllnCallout.AnchorPoint =pPoint;

IFormattedTextSymbolpTextSymbol = new
参考技术A 1.打开arcgis,加入线数据。

2.开始编辑数据。

3.然后,点击创建要素工具。

聊天气泡图片对称拉伸(箭头保持在中间)

参考技术A

一般聊天气泡图片拉伸结果是这样的:

但是如果要求箭头在中间, 表示对某事物的说明, 就会很难实现:

我的实现方法如下, 需要两次拉伸, 第一次拉伸后需要保存图片. 需要注意的只是:
1.保存图片
2.计算第一次拉伸的宽度:第一次拉伸宽度=最终宽度/2+原图宽度/2.
3.如果原图箭头不在正中间, 不适用这个计算公式, 我的原图就是偏的, 所以结果有点偏.

续---2016-05-31
今天对一个图片进行拉伸控制, 不管怎么设置不没有效果, 最后才发现是图片太大了, 显示的时候根本就没有对图片进行拉伸, 反而压扁了...谨记

再续( - )---2016-10-28
上面说的方法有点复杂, 还有一种方法, 使用两个ImageView, 然后用两张图片都是原来气泡图片的一半, 如下图:

以上是关于arcgis气泡标注箭头设置的主要内容,如果未能解决你的问题,请参考以下文章

arcgis10.5没有字符标记符号

arcgis标注牵引线设置成直线

arcgis多地类标注怎么用斜杠隔开

arcgis 标注于标记如何相互转化

arcgis标注不显示是啥原因

arcgis面文件labels点标注后,需要哪个工具或是哪项设置之后,才可以对标注注记进行移动?