我使用此代码创建在ArcMap文本。但我似乎无法得到它,当你放大鳞片状注释文本。

有谁知道如何做到这一点?

//'First setup a color.  We'll use RGB red    
                IRgbColor pRGBcolor = new RgbColor();
                pRGBcolor.Blue = 0;
                pRGBcolor.Red = 255;
                pRGBcolor.Green = 0;

                //'Next, cocreate a new TextElement    
                ITextElement pTextElement = new TextElementClass();

                //'Query Interface (QI) to an IElement pointer and set    
                //'the geometry that was passed in    
                IElement pElement = pTextElement as IElement;
                pElement.Geometry = Point;

                //'Next, setup a font
                stdole.IFontDisp pFontDisp = new stdole.StdFont() as stdole.IFontDisp;
                pFontDisp.Name = "Arial";
                pFontDisp.Bold = true;

                //'Next, setup a TextSymbol that the TextElement will draw with    
                ITextSymbol pTextSymbol = new ESRI.ArcGIS.Display.TextSymbolClass();
                pTextSymbol.Font = pFontDisp;
                pTextSymbol.Color = pRGBcolor;
                pTextSymbol.Size = Size;
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                pTextSymbol.Angle = Angle;
                pTextSymbol.Text = Text;

                //'set the size of the text symbol here, rather than on the font        
                //'Next, Give the TextSymbol and text string to the TextElement    
                pTextElement.Symbol = pTextSymbol;
                pTextElement.Text = pTextSymbol.Text;
                pTextElement.ScaleText = true;

                ESRI.ArcGIS.Carto.IElementProperties3 aoElementPro = pTextElement as ESRI.ArcGIS.Carto.IElementProperties3;
                aoElementPro.ReferenceScale = cGISHelpers.MapDomain.Map.MapScale;
有帮助吗?

解决方案

我们可以很好地添加文本根据规模而改变它的尺寸。对于这一点,我们需要使用IElementProperties3.ReferenceScale属性。

我没有C#代码,但是会附加一些示例VBA代码,你可以修改。

'--------------------------------
Sub ChangeTextElemRefScale()
    Dim pDoc As IMxDocument
    Dim pContainer As IGraphicsContainer
    Dim pElement As IElement
    Dim pTextElement As ITextElement
    Dim pActiveView As IActiveView

    Set pDoc = ThisDocument
    Set pActiveView = pDoc.ActiveView
    Set pContainer = pActiveView

    'Loop through the graphics container
    pContainer.Reset
    Set pElement = pContainer.Next
    While not pElement Is Nothing
        'Get the specific text element
        If TypeOf pElement Is ITextElement Then
           Set pTextElement = pElement
           If pTextElement.Text = "oregon" Then  'change this to your text element's text
                Dim pElemProp As IElementProperties3
                Set pElemProp = pTextElement
                pElemProp.ReferenceScale = 15000000
            End If
        End If
        Set pElement = pContainer.Next
    Wend

    pDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
'--------------------------------

其他提示

据我所知,你不能让一个TextSymbol与地图比例尺一起。这是因为TextElement的不可改变基于地图的程度,但,相反,使用的字体大小来确定它会如何大,以出现在屏幕上。

,我能想到的做到这一点,同时仍然使用TextSymbol是改变点尺寸(和,如果程度足够大,隐藏/显示元件),其程度的变化的最佳方式。我不知道这是什么,你确实需要一个“即注重程度文本控制”的。

或者,不能你只需要使用一个注释层或标签,你想要的文字大小来改变层?

ITextElement得到了一个属性ITextElement.ScaleText。将此设置为true和文本大小会自动适应。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top