To aggregate vector items using the clusterer, assign a MapClustererBase class descendant to the MapDataAdapterBase.Clusterer property. Then optionally, specify the clusterer’s properties.
For example, all predefined clusterers allow you to group items before clustering and customize the appearance of cluster representatives.
To group items, assign AttributeGroupProvider to the MapClusterer.GroupProvider property. Then, set the provider’s AttributeGroupProvider.AttributeName property to location.
To customize the appearance of cluster representatives, assign the required MapItemSettings class descendant object to the MapClusterer.ClusterSettings property.
using System.Windows;
using DevExpress.Xpf.Map;
namespace ClustererSample {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void MarkerClusterer_Clustered(object sender, ClusteredEventArgs e) {
map.ZoomToFitLayerItems();
}
}
}
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ClustererSample"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
x:Class="ClustererSample.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="720" Width="1280">
<Window.Resources>
<XmlDataProvider x:Key="dataSource" Source="Data/TreesCl.xml" />
</Window.Resources>
<Grid>
<dxm:MapControl x:Name="map">
<dxm:ImageTilesLayer>
<dxm:BingMapDataProvider BingKey="YourBingKeyHere"/>
</dxm:ImageTilesLayer>
<dxm:VectorLayer>
<dxm:ListSourceDataAdapter DataSource="{Binding Source={StaticResource dataSource}}"
DataMember="Row">
<dxm:ListSourceDataAdapter.Mappings>
<dxm:MapItemMappingInfo Latitude="lat"
Longitude="lon"/>
</dxm:ListSourceDataAdapter.Mappings>
<dxm:ListSourceDataAdapter.AttributeMappings>
<dxm:MapItemAttributeMapping Name="location"
Member="location"/>
</dxm:ListSourceDataAdapter.AttributeMappings>
<dxm:ListSourceDataAdapter.ItemSettings>
<dxm:MapDotSettings/>
</dxm:ListSourceDataAdapter.ItemSettings>
<dxm:ListSourceDataAdapter.Clusterer>
<dxm:MarkerClusterer Clustered="MarkerClusterer_Clustered">
<dxm:MarkerClusterer.GroupProvider>
<dxm:AttributeGroupProvider AttributeName="location"/>
</dxm:MarkerClusterer.GroupProvider>
<dxm:MarkerClusterer.ClusterSettings>
<dxm:MapDotSettings/>
</dxm:MarkerClusterer.ClusterSettings>
</dxm:MarkerClusterer>
</dxm:ListSourceDataAdapter.Clusterer>
</dxm:ListSourceDataAdapter>
</dxm:VectorLayer>
</dxm:MapControl>
</Grid>
</Window>
Imports System.Windows
Imports DevExpress.Xpf.Map
Namespace ClustererSample
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub MarkerClusterer_Clustered(ByVal sender As Object, ByVal e As ClusteredEventArgs)
map.ZoomToFitLayerItems()
End Sub
End Class
End Namespace
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows
Namespace ClustererSample
''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Partial Public Class App
Inherits Application
End Class
End Namespace
<Application x:Class="ClustererSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClustererSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>