This is a migrated thread and some comments may be shown as answers.

Usage of ToolTipText with cluster

2 Answers 48 Views
Map
This is a migrated thread and some comments may be shown as answers.
perico
Top achievements
Rank 1
Iron
perico asked on 18 Oct 2017, 08:40 AM

Hello,

I am using a map with 2 layers 

Dim layer As New MapLayer("Site")
layer.ClusterStrategy = New ElementClusterStrategy()
layer.ClusterDistance = 50
Me.RadMap1.Layers.Add(layer)
Me.RadMap1.Layers.Add(New MapLayer("Base départ"))

And i add elements to the map like this

Dim element As New MapPin(siteInfo.Location)
element.Text = String.Format("{0}" & vbCrLf & "{1}", siteInfo.Name, siteInfo.adresse)
element.BackColor = Me.colors(siteInfo.identifieur)
element.Tag = siteInfo
element.ToolTipText = String.Format("{0}" & vbCrLf & "{1}", siteInfo.Name, siteInfo.adresse)
Me.RadMap1.Layers(siteInfo.identifieur).Add(element)

 

In this setup, tooltiptext works on pins contained on layer without cluster, but they don't on the one with cluster.

Can you tell me how can i use ToolTipText with cluster ?

 

Thank you

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 19 Oct 2017, 03:27 PM
Hi Perico,

Thank you for writing.

The reported behavior is an issue and I have logged it on our feedback portal, here: https://feedback.telerik.com/Project/154/Feedback/Details/230060-fix-radmap-using-clusters-in-radmap-breaks-the-tooltips-added-to-mappins. I have also updated your Telerik points. Additionally, you can subscribe to the issue and be updated with its status changes. The issue is already in development and a fix will be included in the R1 2018 release.

Until then you can use the workaround below and handle the ToolTipTextNeeded event: 
public partial class Form3 : Form
{
    public Form3()
    {
        InitializeComponent();
 
        MapLayer pointLayer = new MapLayer("PointG");
        pointLayer.ClusterStrategy = new ElementClusterStrategy();
        pointLayer.ClusterDistance = 100;
        this.radMap1.Layers.Add(pointLayer);
 
        MapPin pin1 = new MapPin(new PointG(45d, 15d)) { BackColor = Color.Coral, ToolTipText = "Tool Tip1" };
        MapPin pin2 = new MapPin(new PointG(44d, 18d)) { BackColor = Color.Coral, ToolTipText = "Tool Tip2" };
        this.radMap1.Layers["PointG"].Add(pin1);
        this.radMap1.Layers["PointG"].Add(pin2);
 
        this.SetupProviders();
 
        this.radMap1.ToolTipTextNeeded += radMap1_ToolTipTextNeeded;
    }
 
    private void radMap1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
    {
        MapCluster cluster = sender as MapCluster;
        if (cluster != null && cluster.ClusteredItems.Count == 1)
        {
            cluster.ToolTipText = ((MapPin)cluster.ClusteredItems[0]).ToolTipText;
        }
    }
 
    private void SetupProviders()
    {
        string cacheFolder = @"..\..\cache";
        BingRestMapProvider bingProvider = new BingRestMapProvider();
        bingProvider.Culture = System.Threading.Thread.CurrentThread.CurrentCulture;
        bingProvider.ImagerySet = ImagerySet.Road;
        bingProvider.UseSession = true;
        bingProvider.BingKey = "...";
 
        LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
        bingProvider.CacheProvider = cache;
 
        this.radMap1.MapElement.Providers.Add(bingProvider);
 
        bingProvider.InitializationComplete += bingProvider_InitializationComplete;
    }
 
    private void bingProvider_InitializationComplete(object sender, EventArgs e)
    {
        this.radMap1.BringIntoView(new PointG(45d, 15d), 5);
    }
 
}

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
perico
Top achievements
Rank 1
Iron
answered on 20 Oct 2017, 01:37 PM

Hi Hristo,

Thank you this is exactly what i was looking for.

Tags
Map
Asked by
perico
Top achievements
Rank 1
Iron
Answers by
Hristo
Telerik team
perico
Top achievements
Rank 1
Iron
Share this question
or