Is it possible to create a Balloon Callout with a leader? I am using the following code:

public void DrawText( IActiveView view, BalloonParms balloonParms ) {
    ITextElement textElement = new TextElementClass();
    textElement.Text = balloonParms.TextString;
    textElement.ScaleText = true;                                // ???
    textElement.Symbol = GetTextBalloon( balloonParms );
    IElement element = textElement as IElement;
    element.Geometry = balloonParms.AnchorPoint;
    view.GraphicsContainer.AddElement( element, 0 );
    view.PartialRefresh( esriViewDrawPhase.esriViewGraphics, element, null );

(Ignore the details of GetTextBalloon() it is just standard dance of formatted text, balloon callout, simple fill, and simple line. BalloonParms is just struct with all the settings bundled.) I'm clicking on a polygon feature, getting the point location, and then calling this code. It works like a charm. But there is no leader line!

The IElement interface allows me to set an anchor point and I can fiddle with various settings for the IBalloonCallout.LeaderTolerance but nothing will cause the leader line to appear. I can offset the anchor but still no leader. Is there a way to set both the anchor and another point that will determine where the balloon is drawn? I can't find that prooperty. Am I missing it?

2 Answers 2


This is what I do, there's no leader

public static void DrawHoverStatic(IPoint p, string text = "hello\nthis is working!")
    if (pBalloonCalloutContainer == null) pBalloonCalloutContainer = MapKernel.Get().ActiveView as IGraphicsContainer;

    if (pTextElement == null) pTextElement = new TextElementClass();
    pTextElement.Text = text;

    if (pCallout == null)
        pCallout = new BalloonCalloutClass();
        pCallout.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;

    pCallout.AnchorPoint = p;

    if (pTextSymbol == null)
        pTextSymbol = new TextSymbolClass();
        pTextSymbol.Background = pCallout as ITextBackground;
    pTextElement.Symbol = pTextSymbol;

    pElement = pTextElement as IElement;
    pElement.Geometry = p;

        pBalloonCalloutContainer.AddElement(pElement, 0);
        MapKernel.Get().ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
    catch (Exception ex)
        string message = ex.Message;

  • Yeah, I left out the Activate() but even with it there is no leader. (My code basically boils down (or up) to yours.) Is ArcEngine awesome or what? Is this just another poorly documented 'bug' that I can pay ESRI to tell me about?
    – Chaz
    Commented Dec 22, 2011 at 21:43
  • Oh I'm sorry I misread your question I thought you wanted no leader.
    – patrick
    Commented Dec 29, 2011 at 16:29

If you set the IElement.Geometry to the result of this function and set the IBalloonCallout.AnchorPoint to the user selected location then the leader appears.

private IPoint OffsetAnchor( IActiveView view, IPoint anchor ) {
    IPoint point = new PointClass();
    point.PutCoords( anchor.X, anchor.Y );
    double bumpX = view.Extent.Width / 20d;
    double bumpY = view.Extent.Height / 20d;
    IEnvelope2 envelope = point.Envelope as IEnvelope2;
    envelope.Offset( bumpX, bumpY );
    point.PutCoords( envelope.XMin, envelope.YMin );
    return point;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.