هل هناك طريقة للحصول على نص رسومات لتوسيع نطاق 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;
هل كانت مفيدة؟

المحلول

يمكننا أن نضيف جيدا النص الذي يغير حجمه وفقا للمقياس. لذلك، نحتاج إلى استخدام الخاصية IELEMELEMPROPERTIES3.REFERENCESCESCALE.

ليس لدي رمز 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