Kate
Kate

Reputation: 65

How to show tooltip for OMPoint

I am tring to show tooltip for OMPoint ( com.bbn.openmap.omGraphics.OMPoint ) OMPoint is in layer (OMGraphicHandlerLayer). I do:

layer.setToolTipTex("text");

In this way tooltip is showing in all layer. Do you have any advice because i can't do:

point.setToolTipTex("text");

because OMpoint not hereditary to OMGraphicHandlerLayer

Upvotes: 0

Views: 165

Answers (1)

Psion Omikron
Psion Omikron

Reputation: 23

You need to add logic similar to the following to your layer:

@Override
public String getToolTipTextFor(OMGraphic graphic)
{
    Object value = graphic.getAttribute(OMGraphic.TOOLTIP);
    if (value instanceof String)
    {
        return (String) value;
    }
    return null;
}

The use of the graphic attributes to store the tool tip is optional so long as this method returns the text you want to display.

The map needs to have an InfoDisplayListener registered to it to handle the display of the tool tip on the map. I used the built-in InformationDelegator map component. This provides a number of other UI elements which you turn off if you so choose.

Upvotes: 0

Related Questions