Pregunta

Estoy usando este código para crear texto en ArcMap. Pero me parece que no puede conseguirlo a escala como texto de la anotación al acercar la imagen.

¿Alguien sabe cómo hacer esto?

//'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;
¿Fue útil?

Solución

Podemos muy bien añadir texto que cambia su tamaño de acuerdo a la escala. para esto, tenemos que utilizar la propiedad IElementProperties3.ReferenceScale.

No tengo código C #, pero adjunto algunos ejemplos de código VBA que se puede modificar.

'--------------------------------
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
'--------------------------------

Otros consejos

Que yo sepa, no se puede obtener una TextSymbol a escala junto con el mapa. Esto se debe a la TextElement no se puede cambiar en base a la extensión del mapa, pero, en cambio, utiliza el tamaño de fuente para determinar qué tan grande que va a aparecer en la pantalla.

La mejor manera que puedo pensar para hacerlo sin dejar de utilizar un TextSymbol es cambiar el tamaño de punto (y, si la medida es lo suficientemente grande, ocultar / mostrar el elemento) como los cambios de extensión. No sé de un "control de texto que presta atención a la medida", que es lo que se necesita realmente.

Como alternativa, podría no sólo tiene que utilizar una capa de anotación o etiqueta de la capa donde desee que el tamaño de texto para cambiar?

El ITextElement tiene un ITextElement.ScaleText propiedad. Configure esta opción para true y el tamaño del texto se adaptará automáticamente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top