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

Clustering issue

7 Answers 94 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 26 May 2015, 11:05 PM
I am using the Q3 2014 SP1 version. I enabled clustering, which works. However, for the first load, all pinpoints are clustered even when there is only one point in the area. If I zoom in/out, the clustering fixes itself and the pinpoint is shown correctly instead of showing as a cluster of one point. Any ideas? I would provide a sample, but right now I just don't have the time.

7 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 27 May 2015, 07:30 AM
Hello Jason,

Please check the following bug description here. You can test with our latest release Q1 2015 / Q1 2015 SP and check whether this is still reproducible on your side. If this is not an option, you can try setting AutoExpandWhenSingle = True on the cluster generator and on the clusterr data objects.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason D
Top achievements
Rank 1
Veteran
answered on 28 May 2015, 06:25 PM
I did a bindingRedirect to the new version and the problem is indeed fixed. I do not want to upgrade at this time, though. I attemted to find AutoExpand property earlier but wasn't able to. How can I find and set it via code? I am not using XAML. It appeared I need the DataContext of the MapPinPoint, but it is set Nothing, even after I add the point to the map.
0
Accepted
Petar Mladenov
Telerik team
answered on 01 Jun 2015, 01:02 PM
Hello,

VisualizationLayer uses by default the DefaultClusterGenerator class which sets AutoExpandWhenSingle to True. When creating ClusterData objects , they inherit this setting from the default generator. So practically AutoExpandWhen single won't fix your scenario if you use VisualizationLayer without setting the ClusterGenerator property to non-default generator.

However, you can try the following workaround - iterate over the cluster once the VisualizationLayer is Loaded and expand manually the clusters:
 var allMapLayerCells = this.VisualizationLayer1.ChildrenOfType<Panel>().Where(x => x.GetType().ToString() == "Telerik.Windows.Controls.Map.MapLayerCell");
  
            foreach (var mapLayerCell in allMapLayerCells)
            {
                foreach (var child in mapLayerCell.Children)
                {
                    var contentPres = child as ContentPresenter;
                    if (contentPres != null && contentPres.DataContext is ClusterData)
                    {
                        (contentPres.DataContext as ClusterData).
ClusterState = ClusterState.ExpandedToPolygon;
                    }
                }
            }

We hope this will help you proceed further.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason D
Top achievements
Rank 1
Veteran
answered on 01 Jun 2015, 09:23 PM

Thanks, that will probably work until we are able to upgrade. It works for the most part after some modification. The collection seems to reset so I had to restart the loop.

Friend Sub ExpandSingleClusters()
    Dim lbReset As Boolean
    Dim allMapLayerCells As IEnumerable(Of Windows.Controls.Panel) = VisualizationLayer.ChildrenOfType(Of Windows.Controls.Panel)().Where(Function(x) x.[GetType]().ToString() = "Telerik.Windows.Controls.Map.MapLayerCell")
 
    For Each mapLayerCell As Windows.Controls.Panel In allMapLayerCells
        Do
            lbReset = False
            For Each loPresenter As Windows.UIElement In mapLayerCell.Children
                Dim contentPres As Windows.Controls.ContentPresenter = TryCast(loPresenter, Windows.Controls.ContentPresenter)
                If (contentPres IsNot Nothing) Then
                    Dim loClusterData As ClusterData
                    loClusterData = TryCast(contentPres.DataContext, ClusterData)
                    If (loClusterData IsNot Nothing) AndAlso (loClusterData.Count = 1) Then
                        lbReset = True
                        loClusterData.ClusterState = ClusterState.Expanded
                        Exit For
                    End If
                End If
            Next
            If Not lbReset Then Exit Do
        Loop
    Next
End Sub

The clusters appear to not generate until they are visible on the map. I had to call this function when the map center or zoom changed to address that. The only problem appears to be that sometimes the map's CenterChanged event does not fire when using the mouse to pan.

Unrelated, is there a way to draw a line from the expanded PinPoint to its original location?

0
Petar Mladenov
Telerik team
answered on 04 Jun 2015, 03:21 PM
Hi Jason,

Can you give us exact steps how to reproduce the CenterChanged event not firing ?
You can add PolylineData / LineData . Its start point should be the ClusterData's Location - this should be the unexpanded cluster center. And the end point should be the PinPoint Location.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason D
Top achievements
Rank 1
Veteran
answered on 04 Jun 2015, 05:10 PM
Thanks. Sorry, the CenterChanged is my fault (partially) after looking into it. The map fires tons of CenterChanged events when panning the map using the mouse. Because I only care about the final position, I don't process the event unless the mouse button has been released. Sometimes the mouse button is still down when the last CenterChanged event is fired. Is there a better way? It seems like there should be centerChanging events as long as the mouse is down, but the CenterChanged should only be fired after the user finishes panning. Maybe I could use the LostMouseCapture event instead and get the center then?
0
Petar Mladenov
Telerik team
answered on 09 Jun 2015, 09:42 AM
Hi Jason D,

RadMap has PanningFinished event but it also fires many times during pan. That's why our advice for you is to sue Mouse events instead.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Map
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Petar Mladenov
Telerik team
Jason D
Top achievements
Rank 1
Veteran
Share this question
or