@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
39 lines (38 loc) • 2.29 kB
TypeScript
/**
* A function that queries for unique values from a field in a [Layer](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/).
*
* > [!WARNING]
* >
* > **Known Limitations**
* >
* > [SceneLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/) must have the `supportsRenderer` and `supportsLayerQuery` capabilities enabled unless a predefined [statistics](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/statistics/types/#SummaryStatisticsResult) object is provided to the `statistics` parameter of the method. To check a SceneLayer's capabilities, use the [SceneLayer.getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/#getFieldUsageInfo) method.
* > You cannot generate unique values using SQL expressions for client-side [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/)
* > in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
*
* @since 4.4
*/
import type { UniqueValuesResult, UniqueValuesParameters } from "./types.js";
/**
* Returns an object containing an array of unique values queried from a given field
* (or values returned from an expression) in a [Layer](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/) along with the total count of features that
* belong to the given category.
*
* @param parameters - The function parameters.
* @returns Returns a promise that resolves to [UniqueValuesResult](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/statistics/types/#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);
* });
* });
*/
export default function uniqueValues(parameters: UniqueValuesParameters): Promise<UniqueValuesResult>;