Display a web map with a point feature layer that has feature reduction enabled to aggregate points into clusters.

Use case
Feature clustering can be used to dynamically aggregate groups of points that are within proximity of each other in order to represent each group with a single symbol. Such grouping allows you to see patterns in the data that are difficult to visualize when a layer contains hundreds or thousands of points that overlap and cover each other.
How to use the sample
Pan and zoom the map to view how clustering is dynamically updated. Toggle clustering off to view the original point features that make up the clustered elements. When clustering is toggled on, you can tap on a clustered geoelement to view aggregated information and summary statistics for that cluster as well as a list of containing geoelements. When clustering is disabled and you tap on the original feature you get access to information about individual power plant features.
How it works
- Create a map from a web map
PortalItem. - Get the cluster enabled layer from the map’s operational layers.
- Get the
FeatureReductionfrom the feature layer and setisEnabledto enable or disable clustering on the feature layer. - Use the
onSingleTapGesturemodifier to listen for tap events on the map view. - Identify tapped features on the map using
identify(on:screenPoint:tolerance:returnPopupsOnly:maximumResults:)on the feature layer and pass in the map screen point location. - Get the
Popupfrom the resultingIdentifyLayerResultand use it to construct aPopupView. - Get the
AggregateGeoElementfrom theIdentifyLayerResultand usegeoElementsto retrieve the containedGeoElementobjects. - Use a
FloatingPanelto display the popup information from thePopupViewand the list containing theGeoElementobjects.
Relevant API
- AggregateGeoElement
- FeatureLayer
- FeatureReduction
- GeoElement
- IdentifyLayerResult
About the data
This sample uses a web map that displays the Esri Global Power Plants feature layer with feature reduction enabled. When enabled, the cluster’s symbology shows the color of the most common power plant type, and a size relative to the average plant capacity of the cluster.
Additional information
Graphics in a graphics overlay can also be aggregated into clusters. To do this, set the featureReduction property on the GraphicsOverlay to a new ClusteringFeatureReduction.
Tags
aggregate, bin, cluster, group, merge, normalize, reduce, summarize