简体   繁体   English

如何显示OMPoint的工具提示

[英]How to show tooltip for OMPoint

I am tring to show tooltip for OMPoint ( com.bbn.openmap.omGraphics.OMPoint ) OMPoint is in layer (OMGraphicHandlerLayer). 我正准备显示OMPoint(com.bbn.openmap.omGraphics.OMPoint)的工具提示。OMPoint位于(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 因为OMpoint不是OMGraphicHandlerLayer的遗传

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. 该地图需要注册一个InfoDisplayListener,以处理工具提示在地图上的显示。 I used the built-in InformationDelegator map component. 我使用了内置的InformationDelegator映射组件。 This provides a number of other UI elements which you turn off if you so choose. 这提供了许多其他UI元素,您可以根据需要将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM