2009-05-21 17 views
0

私はこのコードを使用してArcMapでテキストを作成しています。しかし、注釈テキストのように縮尺を変えて拡大表示することはできません。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; 

答えて

1

スケールに応じてサイズを変更するテキストを追加することができます。このためには、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 
'-------------------------------- 
1

私の知る限り、TextSymbolをマップとともに縮尺することはできません。これは、TextElementがマップのエクステントに基づいて変更可能ではなく、代わりにフォントサイズを使用して画面に表示される大きさを判断するためです。

TextSymbolを使用しているときに私が考えることができる最も良い方法は、エクステントの変更に応じてポイントのサイズを変更することです(エクステントが十分大きければ、要素を非表示にする)。私はあなたが本当に必要とするものである「程度に注意を払うテキストコントロール」を知らない。

代わりに、注釈レイヤーを使用したり、テキストサイズを変更したいレイヤーにラベルを付けたりできませんでしたか?

+0

私は小包に寸法を入れるためのツールを構築しています。私はそれをクライアントにとって非常に簡単にする必要があるので、グラフィックテキストを使用してテキストのサイズと位置を設定しようとしています。次に、テキストがどこにあるかをユーザーが幸せにした後、ツールが注釈レイヤに保存します。 –

+0

私は "GIS guy"(上司)と話しました。私たちが思いつくことができる最高のものは、小包ラベルからの注釈レイヤです。クライアントが手動で注釈レイヤ内のラベルを移動できるようにします。そうすれば、エクステント/テキストサイズの変更を保存し、テキストを移動させることもできます。 –

+0

"をアノテーションレイヤ" = ""アノテーションレイヤ " –

0

ITextElementは、プロパティITextElement.ScaleTextを持っています。これをtrueに設定すると、テキストサイズが自動的に適応します。

関連する問題