I'm trying to add text overlay to map but it seems that Placement of a CIMTextGraphic is totally ignored, so text always anchored to geometry by bottom left corner. On image below letters 'A'...'I' are drawn using all possible values of Anchor enum as value of Placement property:
As you can see all letters are drawn at the same point although I set different anchors for them. I use MapPoint (orange circles) as Geometry for CIMTextSymbol. Is there a workaround for this problem? And when it will be fixed?
Solved! Go to Solution.
Hi Max
You will have to set the alignment on the underlying text symbol. So something like this:
//Create a simple text symbol
textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
//alignement properties
textSymbol.HorizontalAlignment = HorizontalAlignment.Left;
textSymbol.VerticalAlignment = VerticalAlignment.Bottom;
//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 line";
//textGraphic.Placement = Anchor.BottomMidPoint;
//Sets symbol to use to draw the text graphic
textGraphic.Symbol = textSymbol.MakeSymbolReference();
//Draw the overlay text graphic
_graphic = this.ActiveMapView.AddOverlay(textGraphic);
Thanks
Uma
Hi Max
You will have to set the alignment on the underlying text symbol. So something like this:
//Create a simple text symbol
textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
//alignement properties
textSymbol.HorizontalAlignment = HorizontalAlignment.Left;
textSymbol.VerticalAlignment = VerticalAlignment.Bottom;
//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 line";
//textGraphic.Placement = Anchor.BottomMidPoint;
//Sets symbol to use to draw the text graphic
textGraphic.Symbol = textSymbol.MakeSymbolReference();
//Draw the overlay text graphic
_graphic = this.ActiveMapView.AddOverlay(textGraphic);
Thanks
Uma