ArcMapでスケールするグラフィックテキストを取得する方法はありますか?

StackOverflow https://stackoverflow.com/questions/893065

  •  23-08-2019
  •  | 
  •  

質問

私は、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