Topic: How to make tooltip always display on screen and follow marker

Hi,
I am trying to make some tooltips and I want them to always display when I create them.
And I want them to follow their marker when I move the map.
I make it with NGUI
Is possible to do that?
Thanks!

Re: How to make tooltip always display on screen and follow marker

Hello.

To always show tooltips use «Online Maps / Advanced / Show Marker Tooltip - Always».
To change the location of the tooltips, use OnlineMapsMarkerBase.OnMarkerDrawTooltip.
Example:
http://infinity-code.com/atlas/online-m … ample.html
Using this action, you can make almost any behavior of tooltips.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to make tooltip always display on screen and follow marker

Thanks for your help,
But I have one more question.
I used OnDrawTooltip() and it have been called a lot of times.
I afraid that it could affect performance.
Do you have any solution to call draw tooltip when I change position of map or change zoom?

Re: How to make tooltip always display on screen and follow marker

This action is invoked for each visible marker for which you need to draw a tooltip.
Did you expect any other behavior for this action?

The built-in tooltips are drawn using the old GUI system.
If you want to draw this with uGUI, you can change this.
Examples:
http://infinity-code.com/atlas/online-m … ample.html
http://forum.infinity-code.com/viewtopi … 1615#p1615

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to make tooltip always display on screen and follow marker

I'm drawing it with nGUI.
I just afraid this action would affect my app's performance when it has many tooltips.
I expect that this action is called when I change position the map or I zoom.

Re: How to make tooltip always display on screen and follow marker

If you draw tooltips using NGUI, you do not need to use OnMarkerDrawTooltip.
You need to modify this script a bit, so that it draws tooltips for all markers.
It's very easy. If you'll have problems with modifying the script, write to me, and I'll modify this script for you.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to make tooltip always display on screen and follow marker

You mean modify OnlineMapsMarkerBase?

Re: How to make tooltip always display on screen and follow marker

You wrote that draw tooltips using NGUI, right?!
If so, you need to modify NGUICustomTooltipExample.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to make tooltip always display on screen and follow marker

Yeah but I used the OnUpdateLate() only. This is my script:

Post's attachments

Attachment icon SM_CreateMarkers.cs 6.49 kb, 321 downloads since 2017-04-20 

Re: How to make tooltip always display on screen and follow marker

Thanks for the script. Now this is much clearer to me.

1. In this case, using OnDrawTooltip is very expensive.
This action will be called every frame, for each visible marker.
Subscribe to OnlineMaps.OnMapUpdated, and update the tooltips only when the map is updated.
Something like:

private void Start() {
...
    map.OnMapUpdated += OnMapUpdated;
...
}

private void OnMapUpdated()
{
   foreach (OnlineMapsMarker marker in map.markers) DrawToolTipForMarker(marker);
}

private void DrawToolTipForMarker(OnlineMapsMarker marker)
{
    TooltipData tdata = marker.customData as TooltipData;
    if (marker.inMapView)
    {
        if (tdata == null)
        {
            // Create tooltip
        }
        // Update tooltip
    }
    else if (tdata != null)
    {
        // Destroy tooltip
    }
}

public class TooltipData 
{
    public GameObject instance;
    public UIWidget widget;
    ...
    // Any other data you need
}

2. You can store all the tooltip data in marker.customData.
3. If the marker is not on the screen, you need to destroy the tooltip.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.