require(["esri/smartMapping/labels/bins"], (binLabelCreator) => { /* code goes here */ });
import * as binLabelCreator from "@arcgis/core/smartMapping/labels/bins.js";
esri/smartMapping/labels/bins
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
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
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.
ParametersSpecificationparams ObjectSee the table below for details of each parameter that may be passed to this function.
Specificationlayer FeatureLayer|CSVLayer|GeoJSONLayer|WFSLayer|OGCFeatureLayer|StreamLayer|OrientedImageryLayer|KnowledgeGraphSublayerThe point layer that has or will have binning enabled.
field StringoptionalThe 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 RendereroptionalThe renderer to set on
layer.featureReduction.renderer
when binning is enabled.ReturnsType 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
-
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 StringThe 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.
-
The return object of the getLabelSchemes() method.