How can I get a marker symbol and a text symbol to appear next to each other?

2824
9
05-31-2012 11:06 AM
RussellWittmer
New Contributor II
Hello all,

I am currently having an issue trying to get a marker symbol and a text symbol to appear side by side.  currently it is not working any help/suggestions would be greatly appreciated on this. 

This is the current implementation:
[ATTACH=CONFIG]14815[/ATTACH]


This is the desired implementation (i moved the symbols manually to show what i want):
[ATTACH=CONFIG]14817[/ATTACH]


This is my code currently

IMarkerElement marker_elm = new MarkerElementClass();
marker_elm.Symbol = (IMarkerSymbol)EventRenderer.Instance.GetClusterSymbol();
IElement markELM = (IElement)marker_elm;

IPoint test = new PointClass();
test.X = -117.230968;
test.Y = 33.786846;
markELM.Geometry = test;

double xmax = markELM.Geometry.Envelope.LowerRight.X;
graphicsContainer.AddElement(markELM, 0);

test.X = xmax;
IRgbColor color = new RgbColorClass();
color.Blue = 255;
color.Green =255;
color.Red = 255;
IFillSymbol fillSym = new SimpleFillSymbolClass();
fillSym.Color = color;

ITextElement textELM = new TextElementClass();
textELM.Text = "THIS IS A TEST";
IFormattedTextSymbol textSymbol = new TextSymbol();

IPoint test2 = new PointClass();
test.PutCoords(xmax, 33.786846);

IBalloonCallout callout = new BalloonCalloutClass();
callout.Symbol = fillSym;     
callout.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;

textSymbol.Background = (ITextBackground)callout;
textELM.Symbol = textSymbol;

IElement elm = (IElement)textELM;
elm.Geometry = test;
graphicsContainer.AddElement(elm, 0);



Again any help would be greatly appreciated.
0 Kudos
9 Replies
LeoDonahue
Regular Contributor


IPoint test2 = new PointClass();
test.PutCoords(xmax, 33.786846);


shouldn't that be test2.PutCoords()?
0 Kudos
by Anonymous User
Not applicable
Original User: Russ.W



IPoint test2 = new PointClass();
test.PutCoords(xmax, 33.786846);


shouldn't that be test2.PutCoords()?


Yes, you are correct but changing it to test2.PutCoords(...) did not change the result.
0 Kudos
LeoDonahue
Regular Contributor
OK,  part 2.

You're assigning the Marker Element to a point geometry.  The lower right X value of a point is still the same location.  You'll have to add some distance there.
0 Kudos
by Anonymous User
Not applicable
Original User: kenbuja

And you'll have to make one more change:

elm.Geometry = test2;
0 Kudos
LeoDonahue
Regular Contributor
Or try getting the MarkerSymbol X-Offset.
0 Kudos
by Anonymous User
Not applicable
Original User: Russ.W

OK,  part 2.

You're assigning the Marker Element to a point geometry.  The lower right X value of a point is still the same location.  You'll have to add some distance there.


And you'll have to make one more change:

elm.Geometry = test2;



Thank you both for your suggestions.  Changing the point did work, but when the user changes map scales it can completely separate the two.  The obvious option is to recompute that point every time when the map scale is changed.  I do wonder is there a way to "attach" the callout box to the marker element?
0 Kudos
LeoDonahue
Regular Contributor
Yes, use a GroupElement.
0 Kudos
by Anonymous User
Not applicable
Original User: Russ.W

Yes, use a GroupElement.


I have just implemented a GroupElement but the MarkerElement and callout are not staying together.  any idea how to keep the two the same distance apart across multiple scale ranges?
0 Kudos
LeoDonahue
Regular Contributor
You can make a TextElement look like a BallonCallout, if all you want to do is place text in a Rectangle with a background color. 

Set the background color of the GroupElement.  Add the MarkerElement and TextElement to your GroupElement.

Or you could also use a ParagraphTextElement, I suppose.
0 Kudos