How to Add Text Overley (Graphic Element) in Arcgis Pro SDK

11-15-2018 07:31 AM
New Contributor III

Hi ,

We are develope commands for arcgis pro sdk 2.2 version.We have text and polygon geometry inputs. How can we add these (text and polgon) graphically on map without annotation or feature class  ? Can do it as Annotation also I can do polygon overlay (using MapView.Active.AddOverlay function) but but I want to create a graph with both polygon and te text like below in picture?How can I solve this problem?

Thaks for Helping


Tags (1)
0 Kudos
4 Replies
Esri Regular Contributor

Here is a code snippet to create an overlay with text. This code is from a sample Map Tool:

internal class AddOverlayWithText : MapTool
        private IDisposable _graphic = null;
        private CIMPolygonSymbol _polygonSymbol = null;
        public AddOverlayWithText()
            IsSketchTool = true;
            SketchType = SketchGeometryType.Polygon;
            SketchOutputMode = SketchOutputMode.Map;

        protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
            //Add an overlay graphic to the map view
            _polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Null, SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid));
            _graphic = await this.AddOverlayAsync(geometry, _polygonSymbol.MakeSymbolReference());

            //define the text symbol
            var textSymbol = new CIMTextSymbol();
            //define the text graphic
            var textGraphic = new CIMTextGraphic();

            await QueuedTask.Run(() =>
                //Create a simple text symbol
                textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
                //Sets the geometry of the text graphic
                textGraphic.Shape = geometry;
                //Sets the text string to use in the text graphic
                textGraphic.Text = "This is my polygon";
                //Sets symbol to use to draw the text graphic
                textGraphic.Symbol = textSymbol.MakeSymbolReference();
                //Draw the overlay text graphic
                _graphic = this.ActiveMapView.AddOverlay(textGraphic);

            return true;

This code creates an overlay like this:

New Contributor III

Thanks for halping Uma,

I had a final question about graphic overlay. Are there any graphic Layer (Graphic Container) for adding overlay in Arcgis pro SDK?  Can we find graphic overlay after save and close/open  pro document (.aprx file) ? Can we use it  like graphic Element in  ArcObject (Finds element from GraphicContainer and use it) or are there any solution to save overlay as graphic?

Thaks for helping.

0 Kudos
Esri Regular Contributor

Hi Taner

No, the graphics are not persisted.



New Contributor III

Hi Umma,

I can display mentioned above graphics on layout but I can not share (export pdf, jpg.etc)  ?How can we solve this problem because our customers also want to see these graphics (export pdf., jpg. etc. files).

Here are above pictures.

Layout picture:


Export pdf file picture:


Thanks for helping. 

0 Kudos