bins

AMD: require(["esri/smartMapping/labels/bins"], (binLabelCreator) => { /* code goes here */ });
ESM: import * as binLabelCreator from "@arcgis/core/smartMapping/labels/bins.js";
Object: esri/smartMapping/labels/bins
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.

Method Overview

Name Return Type Summary Object
Promise<Schemes>

Generates default labelingInfo schemes to be set on a FeatureLayer's featureReduction property.

bins

Method Details

getLabelSchemes

Method
getLabelSchemes(params){Promise<Schemes>}

Generates default labelingInfo schemes to be set on a FeatureLayer's featureReduction property. Returns one or more suggested LabelClasses for FeatureReductionBinning based on its renderer.

Parameters
Specification
params Object

See the table below for details of each parameter that may be passed to this function.

Specification

The point layer that has or will have binning enabled.

field String
optional

The name of the AggregateField to use in the primary label scheme. If not specified, then the label will be based on the aggregate count field.

renderer Renderer
optional

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

Returns
Type Description
Promise<Schemes> 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

Scheme

Type Definition
Scheme

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

Properties
name String

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

fieldName String

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

labelingInfo LabelClass[]

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

Schemes

Type Definition
Schemes

The return object of the getLabelSchemes() method.

Properties
primaryScheme Scheme

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

secondarySchemes Scheme[]

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

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.