arcgis气泡标注箭头设置

arcgis气泡标注箭头设置,第1张

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) asIBalloonCalloutIFillSymbol 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

将标注转换为注记,就是固定的大小了

你新建一个mdb,然后在你标注的图层上右键,有一个Convert Label to Annotation的选项,点开后选择存放路径为mdb,就可以把注记文本输出

这个注记可以设置字体大小号,在它的属性表里统一修改字号列的数值就可以

具体 *** 作步骤如下。

1、首先,要进行处理的数据加载到ArcMap中,在内容列表中右击数据选择Open。如下图所示。

2、打开后,检查属性表中是否存在地名字段。如下图所示。

3、在完成上一步的基础上,在内容列表中右击数据,打开属性对话框,检查Expression是否为Name。如下图所示。

4、在内容列表内,右击选择LabelFeatures。如下图所示。

5、最后,地名添加成功。如下图所示。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/7959480.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存