crx509
路人甲
路人甲
  • 注册日期2005-04-27
  • 发帖数20
  • QQ
  • 铜币192枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1933回复:6

[求助]如何在标注中添加背景框

楼主#
更多 发布于:2006-07-21 16:31
<P> 我现在可以显示标注了,但是我想实现这样的效果,据说在字的后面加个那种黄色的框,把字圈起来,该怎么做呀?</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-07-22 19:46
<PRE>Private Sub TextLabel(ByVal LabelText As String, ByVal LabelPlacement As IPoint)
    'dim and set new text element
    Dim pTextEl As ITextElement
    Set pTextEl = New TextElement
    'check
    If pTextEl Is Nothing Then
        MsgBox "Text Element Object Not Set", , "Error - Text Label"
        Exit Sub
    End If
    'set text element text
    pTextEl.Text = LabelText
    'dim and set color object
    Dim pColor As IRgbColor
    Set pColor = Common.GetRGBColor(255, 255, 255)
    'check
    If pColor Is Nothing Then
        MsgBox "RGB Color Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Exit Sub
    End If
    'dim and set balloon callout object
    Dim pBallCall As IBalloonCallout
    Set pBallCall = New BalloonCallout
    'check
    If pBallCall Is Nothing Then
        MsgBox "Balloon Callout Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pColor = Nothing
        Exit Sub
    End If
    'dim and set fill symbol for callout element
    Dim pFill As IFillSymbol
    Set pFill = New SimpleFillSymbol
    'check
    If pFill Is Nothing Then
        MsgBox "Fill Symbol Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pBallCall = Nothing
        Set pColor = Nothing
        Exit Sub
    End If
    'set fill color
    pFill.Color = pColor
    'dim and set line symbol for
    'callout outline
    Dim pLS As ILineSymbol
    Set pLS = New SimpleLineSymbol
    'check
    If pLS Is Nothing Then
        MsgBox "Line Symbol Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pBallCall = Nothing
        Set pColor = Nothing
        Set pFill = Nothing
        Exit Sub
    End If
    'reset color object
    Set pColor = Nothing
    Set pColor = New RgbColor
    pColor.RGB = 0
    'set outline color
    pLS.Color = pColor
    'set fill symbol outline property to line symbol
    pFill.Outline = pLS
    'set balloon callout object properties
    With pBallCall
        'symbol property to fill symbol
        Set .Symbol = pFill
        'set label anchor point
        .AnchorPoint = LabelPlacement
        'leader tolerance to initially place
        'label directly on anchor point
        .LeaderTolerance = 0
        'callout style
        .Style = esriBCSRoundedRectangle
    End With
    'now set properties to complete element
    'dim and set text backgrount object
    Dim pTextBack As ITextBackground
    Set pTextBack = pBallCall
    'check
    If pTextBack Is Nothing Then
        MsgBox "Text Background Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pBallCall = Nothing
        Set pColor = Nothing
        Set pFill = Nothing
        Set pLS = Nothing
        Exit Sub
    End If
    'dim and set formatted text symbol
    'for specialized callout element
    Dim pLabelSymbol As IFormattedTextSymbol
    Set pLabelSymbol = New TextSymbol
    'check
    If pLabelSymbol Is Nothing Then
        MsgBox "Formatted Text Symbol Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pTextBack = Nothing
        Set pBallCall = Nothing
        Set pColor = Nothing
        Set pFill = Nothing
        Set pLS = Nothing
        Exit Sub
    End If
    'set label symbol properties
    With pLabelSymbol
        Set .Background = pTextBack
        .Size = 10
    End With
    'set text element custom symbol
    pTextEl.Symbol = pLabelSymbol
    'dim and set element properties object
    Dim pElemProp As IElementProperties
    Set pElemProp = pTextEl
    'check
    If pElemProp Is Nothing Then
        MsgBox "Element Properties Object Not Set", , "Error - Text Label"
        Set pTextEl = Nothing
        Set pLabelSymbol = Nothing
        Set pTextBack = Nothing
        Set pBallCall = Nothing
        Set pColor = Nothing
        Set pFill = Nothing
        Set pLS = Nothing
        Exit Sub
    End If
    'set element properties
    pElemProp.Type = "Jeffco Callout"
    'add graphic to map
    AddBalloonElement pElemProp, LabelPlacement
    'destroy variables
    Set pTextEl = Nothing
    Set pLabelSymbol = Nothing
    Set pTextBack = Nothing
    Set pBallCall = Nothing
    Set pColor = Nothing
    Set pFill = Nothing
    Set pLS = Nothing
    Set pElemProp = Nothing
End Sub

Public Sub AddBalloonElement(LabelElement As IElement, LabelPosition As IGeometry)
    
    Dim pMap As IMap
    Dim mGC As IGraphicsContainer
    
    Set pMap = Common.GetFocusMap
    Set mGC = pMap
    
    If TypeOf LabelPosition Is IEnvelope Then
        Dim pEnv As IEnvelope
        Set pEnv = LabelPosition
        LabelElement.Geometry = pEnv
    Else
        LabelElement.Geometry = LabelPosition
    End If
    
    mGC.AddElement LabelElement, 0
      
End Sub</PRE>
举报 回复(0) 喜欢(0)     评分
crx509
路人甲
路人甲
  • 注册日期2005-04-27
  • 发帖数20
  • QQ
  • 铜币192枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-07-24 08:40
<P>十分感谢楼上的 ,多谢了!!</P>
举报 回复(0) 喜欢(0)     评分
chenjinbo
路人甲
路人甲
  • 注册日期2006-06-04
  • 发帖数26
  • QQ
  • 铜币195枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-08-24 16:29
回复:(crx509)[求助]如何在标注中添加背景框
<P>怎么调用后啥都没显示?</P>
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-08-24 17:59
<img src="images/post/smile/dvbbs/em03.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
hahaaluo
路人甲
路人甲
  • 注册日期2006-08-05
  • 发帖数146
  • QQ
  • 铜币591枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-08-24 20:40
为什么老大都是用VB的呢
举报 回复(0) 喜欢(0)     评分
hahaaluo
路人甲
路人甲
  • 注册日期2006-08-05
  • 发帖数146
  • QQ
  • 铜币591枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2006-08-24 20:41
<P>有没有C#的 ???...........</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部