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

Cluster Location limitation and Bounds bug

2 Answers 41 Views
Map
This is a migrated thread and some comments may be shown as answers.
Magnus
Top achievements
Rank 1
Magnus asked on 28 Feb 2018, 12:16 PM

It seems like there's a limitation to Cluster locations and a bug regarding its Bounds. I noticed that the location of a Cluster is always at the location of the first item added to it. I would expect that it actually would be at the center of all added items. Looking at the ClusterData.Add method it seems like it would be easy to update the Cluster-location there since the bounds are updated each time a new item is added. I tried solving it by overriding the DefaultClusterGenerator like the code below, but then I noticed that the calculation for the Bounds are actually wrong in the ClusterData.Add method. The last Math.Min should be a Math.Max. In the end I had to calculate the Bounds myself, and then update the Cluster Location.

 

public class ClusterGenerator : DefaultClusterGenerator
 
{
    public override ClusterData CreateCluster(Location center, object item)
    {
        var clusterData = base.CreateCluster(center, item);
        clusterData.AutoCalculateBounds = true;
 
        clusterData.PropertyChanged += this.ClusterDataOnPropertyChanged;
        return clusterData;
    }
    private void ClusterDataOnPropertyChanged(object sender, PropertyChangedEventArgs args)
    {
        // Check if an item has been added or removed
        if (args.PropertyName == nameof(ClusterData.Count))
        {
            var clusterData = sender as ClusterData;
            if (!clusterData.Bounds.IsEmpty)
            {
                clusterData.Location = clusterData.Bounds.Center;
            }
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 05 Mar 2018, 07:55 AM
Hello Magnus,

Thank you for the provided code snippet.

I am currently investigating this behavior. I will contact you again as soon as I have more information about your case.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Petar Mladenov
Telerik team
answered on 06 Mar 2018, 02:58 PM
Hello Magnus,

We understand your requirement for the center of the cluster. This is a valid request and you can submit it in our feedback portal. To be honest, we need to evaluate the performance and the behavior of the cluster if we change the way its Location is calculated. As for the Bounds, we managed to isolate the issue and a fix for it will be available in the in the build next week. We logged it in our portal and increased your telerik account points as thanks for your cooperation.

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Map
Asked by
Magnus
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Petar Mladenov
Telerik team
Share this question
or