Usage of ToolTipText with cluster

3 posts, 1 answers
  1. perico
    perico avatar
    28 posts
    Member since:
    Dec 2006

    Posted 18 Oct 2017 Link to this post

    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. Answer
    Hristo
    Admin
    Hristo avatar
    1294 posts

    Posted 19 Oct 2017 Link to this post

    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.
  3. perico
    perico avatar
    28 posts
    Member since:
    Dec 2006

    Posted 20 Oct 2017 Link to this post

    Hi Hristo,

    Thank you this is exactly what i was looking for.

Back to Top