Skip to content
import { getLabelSchemes } from "@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.

See also

Functions

getLabelSchemes

Function

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
ParameterTypeDescriptionRequired
parameters

The function parameters.

Returns
Promise<Schemes | null | undefined>

Returns an object containing suggested primary and secondary labeling schemes to be set on the layer's featureReduction property.

Example
// Sets a suggested label scheme for the binning config based on its renderer
const { primaryScheme } = await binLabelCreator.getLabelSchemes({
layer: featureLayer
});
const featureReduction = featureLayer.featureReduction.clone();
featureReduction.labelingInfo = primaryScheme.labelingInfo;
featureLayer.featureReduction = featureReduction;

Type definitions

SchemeParameters

Type definition

field

Property
Type
string | undefined

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

Property
Type
RendererUnion | undefined

The renderer to set on layer.featureReduction.renderer when binning is enabled.

layer

Property
Type
BinningSupportedLayer

The point layer that has or will have binning enabled.

Scheme

Type definition

Contains suggested labelingInfo to be set on the layer's featureReduction.labelingInfo.

name

Property
Type
string

The name of the generated binning labeling scheme. This can be used in the UI of web map authoring apps.

labelingInfo

Property
Type
LabelClass[]

An array of LabelClass objects to set on the layer's featureReduction.labelingInfo property.

fieldName

Property
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

Type definition

The return object of the getLabelSchemes() method.

primaryScheme

Property
Type
Scheme

Includes the primary labeling scheme suggested for the input layer's bins.

secondarySchemes

Property
Type
Scheme[]

Includes secondary labeling schemes suggested for the input layer's bins.