Skip to main content

AttributeGroupProvider.AttributeName Property

Gets or sets the attribute name used to group map items by its value.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v23.2.dll

NuGet Package: DevExpress.Win.Map

Declaration

[DefaultValue(null)]
public string AttributeName { get; set; }

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.

Map item clusters

Follow the steps below to cluster map items:

  1. Assign an object of a class that implements the IClusterer interface to the MapDataAdapterBase.Clusterer property.

  2. 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.

  3. 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.

  4. 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.

View Example

    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();
    }
}
See Also