import { getLabelSchemes } from "@arcgis/core/smartMapping/labels/bins.js";const { getLabelSchemes } = await $arcgis.import("@arcgis/core/smartMapping/labels/bins.js");- Since
- ArcGIS Maps SDK for JavaScript 4.27
This object contains a helper method for generating default labels to be set on
a layer's binning configuration.
The default label is based on the FeatureReductionBinning.renderer. In most cases the default label configuration will
be the total number of features in the bin. This value will be rounded and formatted (e.g. instead of 2385, the
bin label will display 2.4k).
This includes secondary labeling schemes you can experiment with using on your bins. This module only applies to layers with a point geometry type.
Functions
| Name | Return Type | Object |
|---|---|---|
| | ||
| | |
| | |
| |
getLabelSchemes
Generates default FeatureReductionBinning.labelingInfo schemes to be set on a FeatureLayer's FeatureLayer.featureReduction property. Returns one or more suggested LabelClasses for FeatureReductionBinning based on its renderer.
- Signature
-
getLabelSchemes (parameters: SchemeParameters): Promise<Schemes | null | undefined>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameters | The function parameters. | |
Example
// Sets a suggested label scheme for the binning config based on its rendererconst { primaryScheme } = await binLabelCreator.getLabelSchemes({ layer: featureLayer});
const featureReduction = featureLayer.featureReduction.clone();featureReduction.labelingInfo = primaryScheme.labelingInfo;featureLayer.featureReduction = featureReduction;Type definitions
SchemeParameters
field
The name of the AggregateField.name to use in the primary label scheme. If not specified, then the label will be based on the aggregate count field.
renderer
- Type
- RendererUnion | undefined
The renderer to set on layer.featureReduction.renderer when binning is enabled.
Scheme
Contains suggested labelingInfo to be set on the layer's featureReduction.labelingInfo.
name
- Type
- string
The name of the generated binning labeling scheme. This can be used in the UI of web map authoring apps.
labelingInfo
- Type
- LabelClass[]
An array of LabelClass objects to set on the layer's featureReduction.labelingInfo property.
fieldName
- Type
- string
The name of the aggregate field used in the labeling scheme. This can be used in the UI of web map authoring apps.
Schemes
The return object of the getLabelSchemes() method.
primaryScheme
- Type
- Scheme
Includes the primary labeling scheme suggested for the input layer's bins.
secondarySchemes
- Type
- Scheme[]
Includes secondary labeling schemes suggested for the input layer's bins.