Clustering issue

8 posts, 1 answers
  1. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 26 May 2015 Link to this post

    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.
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 27 May 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 28 May 2015 in reply to Petar Mladenov Link to this post

    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.
  5. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Jun 2015 Link to this post

    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
  6. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 01 Jun 2015 in reply to Petar Mladenov Link to this post

    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?

  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 04 Jun 2015 Link to this post

    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
  8. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 04 Jun 2015 in reply to Petar Mladenov Link to this post

    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?
  9. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 09 Jun 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready