AttributeGroupProvider.AttributeName Property
Gets or sets the attribute name used to group map items by its value.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.1.dll
NuGet Package: DevExpress.Win.Map
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | null | A String object, that is the name of the attribute. |
Example
This example shows how to cluster vector map items.
Follow the steps below to cluster map items:
Assign an object of a class that implements the IClusterer interface to the MapDataAdapterBase.Clusterer property.
To group the items based on an attribute, assign an AttributeGroupProvider object to the MapClustererBase.GroupProvider property. Set the
AttributeGroupProvider.AttributeName
property to the item attribute name that should be used to cluster items. After that, only items with an equal attribute value are grouped into the same cluster.Design a class that implements the IClusterItemFactory interface to customize the appearance of clusters. Then, call the MapClustererBase.SetClusterItemFactory method with an object of the class to assign the required factory object to the clusterer.
Select a layout algorithm that defines how to position nested map items when a cluster is expanded. To do this, assign one of the following objects to the InteractiveClusterModeBase.ExpandedClusterLayout property.
VectorItemsLayer VectorLayer { get { return (VectorItemsLayer)map.Layers["VectorLayer"]; } }
// ...
ListSourceDataAdapter DataAdapter { get { return (ListSourceDataAdapter)VectorLayer.Data; } }
// ...
private void Form1_Load(object sender, EventArgs e) {
DataAdapter.DataSource = LoadData();
DistanceBasedClusterer clusterer = new DistanceBasedClusterer {
ItemMaxSize = 60,
ItemMinSize = 14,
GroupProvider = new AttributeGroupProvider {
AttributeName = "LocationName"
}
};
clusterer.SetClusterItemFactory(new CustomClusterItemFactory());
DataAdapter.Clusterer = clusterer;
DataAdapter.PropertyMappings.Add(new MapDotSizeMapping { DefaultValue = 14 });
MouseHoverInteractiveClusterMode interactiveMode = new MouseHoverInteractiveClusterMode();
interactiveMode.ExpandedClusterLayout = new ExpandedClusterAdaptiveLayout();
map.InteractiveClusterMode = interactiveMode;
}
// ...
class CustomClusterItemFactory : IClusterItemFactory {
public MapItem CreateClusterItem(IList<MapItem> objects) {
return new MapDot();
}
public void CustomizeCluster(MapItem cluster) {
((MapDot)cluster).TitleOptions.Pattern = cluster.ClusteredItems.Count.ToString();
}
}