Skip to content
import uniqueValues from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
Since
ArcGIS Maps SDK for JavaScript 4.4

A function that queries for unique values from a field in a Layer.

Known Limitations

SceneLayers must have the supportsRenderer and supportsLayerQuery capabilities enabled unless a predefined statistics object is provided to the statistics parameter of the method. To check a SceneLayer's capabilities, use the SceneLayer.getFieldUsageInfo() method. You cannot generate unique values using SQL expressions for client-side FeatureLayers in a SceneView.

Functions

NameReturn TypeObject

uniqueValues

Function

Returns an object containing an array of unique values queried from a given field (or values returned from an expression) in a Layer along with the total count of features that belong to the given category.

Signature
uniqueValues (parameters: UniqueValuesParameters): Promise<UniqueValuesResult>
Parameters
ParameterTypeDescriptionRequired
parameters

The function parameters.

Returns
Promise<UniqueValuesResult>

Returns a promise that resolves to UniqueValuesResult.

Example
let layer = new FeatureLayer({
portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }
});
uniqueValues({
layer: layer,
field: "Candidate"
}).then(function(response){
// prints each unique value and the count of features containing that value
let infos = response.uniqueValueInfos;
infos.forEach(function(info){
console.log("CANDIDATE: ", info.value, " # OF CAMPAIGN STOPS: ", info.count);
});
});