【问题标题】:Is there a way to get graphic text to scale in ArcMap?有没有办法让图形文本在 ArcMap 中按比例缩放?
【发布时间】:2010-10-27 22:37:19
【问题描述】:

我正在使用此代码在 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;

【问题讨论】:

    标签: gis arcgis arcobjects arcmap


    【解决方案1】:

    ITextElement 有一个属性ITextElement.ScaleText。将此设置为true,文本大小将自动适应。

    【讨论】:

      【解决方案2】:

      我们可以很好地添加根据比例改变大小的文本。为此,我们需要使用 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
      '--------------------------------
      

      【讨论】:

        【解决方案3】:

        据我所知,您无法将 TextSymbol 与地图一起缩放。这是因为 TextElement 不能根据地图的范围进行更改,而是使用字体大小来确定它将在屏幕上显示的大小。

        在仍然使用 TextSymbol 的同时,我能想到的最佳方法是随着范围的变化改变点的大小(如果范围足够大,则隐藏/显示元素)。我不知道您真正需要的“关注范围的文本控件”。

        或者,您不能只使用注释层或标记要更改文本大小的层吗?

        【讨论】:

        • 我正在构建一个用于在包裹上标注尺寸的工具。我们需要让客户端变得非常容易,所以我尝试使用图形文本来定位和设置文本的大小,然后在用户对文本所在的位置感到满意后,该工具会将其保存在注释层中。
        • 我和我们的“GIS 人”(我的老板)谈过了,我们能想到的最好办法是从地块标签中创建一个注释层,然后让您的客户手动移动注释中的标签层。这样您就可以保留范围/文本大小的更改,还可以移动文本。
        • "到注释层" = "创建注释层"
        猜你喜欢
        • 2014-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-03
        • 1970-01-01
        • 1970-01-01
        • 2022-06-10
        相关资源
        最近更新 更多