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

Clustering Help Needed !!

10 Answers 41 Views
Map
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 18 Apr 2018, 01:32 PM

First of all , Hello !

Im using maps and i have question about clustering. Currently im manipulating with 1000 objects and displaying them on my map and clustering them(  of course).
But on zoom level 7 i have arround 100 clusters. How can i set that on zoom level 7 i have maybe 5 clusters .  Or can you give me idea or example where you are setting different condition for clusters

in attachment is picture on zoomLevel=7 and clusters

Thank you

10 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Apr 2018, 11:55 AM
Hi Robert,

VisualizationLayer has IClusterGenerator instance member which is responsible for the clustering behavior. It has predefined distances for all zoom levels which participate in the calculations whether item belongs to cluster or not. To change this predefined list of distances you can use the following code:
this.VisualizationLayer1.ClusterGenerator = new DefaultClusterGenerator()
           {
               CloseDistance = new double[]
               {
                   20,
                   10,
                   5,
                   2.5,
                   1.25,
                   0.6,
                   0.3,
                   0.15,
                   0.075,
                   0.037,
                   0.018,
                   0.009,
                   0.0045,
                   0.0022,
                   0.0011,
                   0.00055,
                   0.00027,
                   0.000135,
                   0.000067,
                   0.000033,
                   0.000016,
                   0.000008,
                   0.000004,
                   0.000002,
                   0.000001
               }
           };
I have pasted the default numbers used internally. 

To better understand the cluster calculations , I will paste the CloseDistance property and IsItemInClusterRegion method of the DefaultClusterGenerator class:

/// <summary>
        /// Gets or sets array of the doubles which define close distance
        /// between 2 locations in degrees for every zoom level.
        /// </summary>
        /// <remarks>If distance between 2 locations for the given zoom level is
        /// less than value in the array, then we consider these 2 locations as close ones.
        /// Close locations should be combined into 1 cluster.</remarks>
        public double[] CloseDistance
        {
            get
            {
                return this.closeDistance;
            }
 
            set
            {
                this.closeDistance = value;
            }
        }

/// <summary>
        /// Detects whether given original data item belongs to the region of the specified cluster.
        /// </summary>
        /// <param name="cluster">Cluster.</param>
        /// <param name="info">Map object information.</param>
        /// <param name="zoomLevel">Zoom level.</param>
        /// <returns>true - if data item belongs to the region of the specified cluster.</returns>
        public virtual bool IsItemInClusterRegion(ClusterData cluster, MapObjectInfo info, int zoomLevel)
        {
            Location itemLocation = this.Layer.GetLocationFromInfo(info);
 
            bool isClose = false;
 
            if (zoomLevel > 0)
            {
                double width = Math.Abs(cluster.Location.Longitude - itemLocation.Longitude);
                double height = Math.Abs(cluster.Location.Latitude - itemLocation.Latitude);
                isClose = width < this.closeDistance[zoomLevel - 1]
                    && height < this.closeDistance[zoomLevel - 1];
            }
 
            return isClose;
        }

In future, we will aim at describing this generator in our documentation.

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.
0
Robert
Top achievements
Rank 1
answered on 30 Apr 2018, 11:52 AM

can you maybe send example of implementing it  so i can see it on example ?

thank you

0
Petar Mladenov
Telerik team
answered on 02 May 2018, 05:53 AM
Hi Robert,

Please find the attached project in which I have changed the clustering distance for level 3:
public MainWindow()
       {
           InitializeComponent();
 
          this.VisualizationLayer1.ClusterGenerator = new DefaultClusterGenerator()
          {
              CloseDistance = new double[]
              {
                  20,
                  10,
                  8, // default is 5
                  2.5,
                  1.25,
                  0.6,
In the result picture you will notice the difference. Increasing the cluster distance means objects go into cluster easier and the number of total clusters decrease.

I hope this will help you move forward.

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.
0
Robert
Top achievements
Rank 1
answered on 24 May 2018, 08:55 AM
Thank you for your example
i see the point.
But i have one problem
I need to put zoom level really high (<15) so my  zoom level (1-15) will work

<telerik:RadMap x:Name="radMap" Grid.Row="1" ZoomLevel="10">

if i put zoom level=1 Clustering close distance WONT work . iF i put zoomLevel=15 Clustering close distance will work
If i delete zoomLevel and put it by default Clustering CloseDistance also doesnt work

really weird .
Maybe Bug ?? 
Thank you
0
Petar Mladenov
Telerik team
answered on 29 May 2018, 06:32 AM
Hi Robert,

In the attached project, default close distance for zoom level 1 is 20. If you increase it to 200, you will notice there will be single cluster on zoomlevel 1. If you decrease it to 0.02 there will be practically no clusters. You can see the results in the attached pictures. Could you please elaborate a bit more on your scenario and why zoomlevel 1 is problematic. Can you send us some real data (locations) and clsuter distances that we can debug locally and double check for an issue in RadMap's internal code. Thank you in advance.

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.
0
Petar Mladenov
Telerik team
answered on 29 May 2018, 06:32 AM
Hi Robert,

In the attached project, default close distance for zoom level 1 is 20. If you increase it to 200, you will notice there will be single cluster on zoomlevel 1. If you decrease it to 0.02 there will be practically no clusters. You can see the results in the attached pictures. Could you please elaborate a bit more on your scenario and why zoomlevel 1 is problematic. Can you send us some real data (locations) and cluster distances that we can debug locally and double check for an issue in RadMap's internal code. Thank you in advance.

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.
0
Robert
Top achievements
Rank 1
answered on 30 May 2018, 07:46 AM

I think you didnt understand me.
i attached pictures of 2 scenario.

1 scenario when i put grid zoom level=15 and then i zoom out and see clustering okay.

2 scenario: if i put grid zoom level=1 then clustering is not working .. also if i delete grid zoom level clustering doesnt work .

Thank you

0
Petar Mladenov
Telerik team
answered on 31 May 2018, 03:41 PM
Hello Robert,

We understand that by some reason clustering feature does not create clusters in your scenario for initial zoom level 1. Can you send us you RadMap code - its XAML and code behind and some of your locations displayed on the map. Probably this will help us better investigate and give an appropriate advice for your business case. Meanwhile, you can take a quick look at the following list of properties for configuring the cluster generation:

RadMap VisualizationLayer clustering

Can you double check if you use the default values of these properties ?

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.
0
Robert
Top achievements
Rank 1
answered on 01 Jun 2018, 01:35 PM
https://www.dropbox.com/s/7yxck3vflrc20i2/Ftth.rar?dl=0

link to download 2 files because i canot post rar or zip inside reply
0
Martin Ivanov
Telerik team
answered on 04 Jun 2018, 09:00 AM
Hi Robert,

The file is missing (error 404).

What I could suggest in order to prevent sharing your project publicly is to open a new support ticket from your telerik.com account.

Regards,
Martin Ivanov
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
Robert
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Robert
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or