문제

이 코드를 사용하여 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
'--------------------------------

다른 팁

내가 아는 한, 당신은지도와 함께 스케일을 얻을 수 없습니다. 텍스트 범위는 맵의 범위를 기반으로 텍스트 범위가 변경 될 수 없지만 대신 글꼴 크기를 사용하여 화면에 얼마나 큰지를 결정합니다.

여전히 텍스트 상징을 사용하는 동안 그렇게 할 수있는 가장 좋은 방법은 포인트 크기를 변경하는 것입니다 (그리고 범위가 충분히 크면 요소를 숨기거나 표시). 나는 "범위에주의를 기울이는 텍스트 제어"를 모른다.

또는 텍스트 크기가 변경되기를 원하는 위치에 주석 레이어를 사용하거나 레이어에 레이블을 붙일 수 없습니까?

그만큼 ITextElement 재산이 있습니다 ITextElement.ScaleText. 이것을 설정하십시오 true 텍스트 크기가 자동으로 적응됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top