Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

WinForms & WPF Map Control - Clustering (Coming soon in v15.2)

$
0
0

Set for release in v15.2 is clustering support for both our WinForms and WPF Map Controls. For those unfamiliar with this feature, its designed to aggregate map items and perform data density analysis.

WinForms and WPF Map Control - Data Clustering

Once shipped, the DevExpress Map Control will support 2 clustering algorithms:

  • Distance Based: joins items - whose separation is smaller than a specified threshold - into a single cluster. The cluster's indicator is calculated as the mean of items.
  • Marker: joins items - whose distance to the central item is smaller than a specified threshold - into a single cluster. The cluster indicator matches the central item.

You can also implement a custom clustering algorithm by inheriting from the MapClustererBase class (WPF) or implementing the IClusterer (WinForms) interface.

Groups

Predefined clusterers allow you to separate items into groups prior to clustering (for instance, to group items by attribute values before clustering).

WinForms & WPF Map Control - Clustering Groups
 

It's relatively straightforward to implement this feature for our WPF Map Control - You simply assign the MapClustererGroupProviderBase class descendant object to the GroupProperty property:

<dxm:ListSourceDataAdapter.Clusterer>
    <dxm:DistanceBasedClusterer>
       <dxm:DistanceBasedClusterer.GroupProvider>
            <dxm:AttributeGroupProvider AttributeName="LocationName"/>
        </dxm:DistanceBasedClusterer.GroupProvider>
    </dxm:DistanceBasedClusterer>
 </dxm:ListSourceDataAdapter.Clusterer>

If you're using the WinForms version of our Map Control, you would assign an object implementing the IClustererGroupProvider interface to the GroupProperty property:

ListSourceDataAdapter vectorDataAdapter = newListSourceDataAdapter();
// Several data adapter configurations...
vectorDataAdapter.Clusterer = newDistanceBasedClusterer {
    GroupProvider = newAttributeGroupProvider { AttributeName = "LocationName" }
};


Custom Indicators

As you'd expect, you can customize cluster indicators as needed (by using custom cluster item factories for WinForms or item settings for WPF).

WinForms & WPF Map Control - Custom Clustering Indicators


To customize indicators for the WinForms Map Control, use the clusterer's SetClusterFactory(IClusterItemFactory) method to specify the factory used to generate cluster indicators:

publicclassCustomClusterItemFactory : IClusterItemFactory {
// Code to generate items...
}
 
// Additional Code...
clusterer.SetClusterItemFactory(newCustomClusterItemFactory());

For WPF, specify the required MapItemSetting class descendant object to the ClusterSettings property of the clusterer:

<dxm:DistanceBasedClusterer>
   <dxm:DistanceBasedClusterer.ClusterSettings>
       <dxm:MapCustomElementSettings ContentTemplate="{Binding Source={StaticResource itemTemplate}}"/>
   </dxm:DistanceBasedClusterer.ClusterSettings>
</dxm:DistanceBasedClusterer>

===========================

We'd love to get your feedback on this new Map Clustering feature. How likely are you to use it in your next WinForms or WPF project?


Viewing all articles
Browse latest Browse all 2370

Trending Articles