
1、单击路线类型下拉箭头,然后单击曲线。
2、单击下拉箭头,然后选择要用于确定曲线的两个参数。输入合适的参数值,距离值将使用地图单位,输入曲线的弦方向。
3、单击下拉箭头以选择曲线是向右弯曲还是向左弯曲,单击添加。
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
没有编辑线要素。首先要先添加线要素,然后对其编辑,先要创建要素,然后选择模板的线,就不会有多出来的,如果不需要的可以删掉。
也可以对分出的箭头进行标注,就能知道这个线代表着什么,也能够根据点的属性画出不同的方向的箭头,需要的也可以参照风向图的制作,矢量的制作,来调整旋转方向的大小。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)