require(["esri/smartMapping/heuristics/scaleRange"], (scaleRange) => { /* code goes here */ });
import scaleRange from "@arcgis/core/smartMapping/heuristics/scaleRange.js";
esri/smartMapping/heuristics/scaleRange
Function for determining suggested min and max scale ranges for an input layer.
Known Limitations
- Input SceneLayers must meet the following conditions:
- SceneLayers without the
supportsRenderer
andsupportsLayerQuery
capabilities enabled, unless a predefined statistics object is passed to thestatistics
parameter of the method in conjunction with the layer. To check a SceneLayer's capabilities, use the getFieldInfoUsage() method.
- SceneLayers without the
Method Overview
Name | Return Type | Summary | Function |
---|---|---|---|
Promise<ScaleRangeResult> | Generates a suggested scale range (i.e. | scaleRange |
Method Details
-
scaleRange
scaleRange(params){Promise<ScaleRangeResult>}
-
Generates a suggested scale range (i.e. minScale and maxScale) to apply to the input
layer
. These values suggest the best scale range for viewing the input layer.ParametersSpecificationparams ObjectSee the table below for details about parameters that may be passed to this function.
Specificationlayer FeatureLayer|SceneLayer|CSVLayer|OGCFeatureLayer|PointCloudLayer|GeoJSONLayer|WFSLayer|StreamLayer|OrientedImageryLayer|KnowledgeGraphSublayer|SubtypeGroupLayer|SubtypeSublayerThe layer for which to generate a suggested min/max scale range.
view ViewoptionalThe SceneView or MapView where the layer will be rendered. This property is required when generating a scale range for any layer that is not tiled.
sampleSize NumberoptionalDefault Value: 500The number of features in the
layer
to sample for spatial statistics. A higher sample size will yield more precise results. However, higher sample sizes also require more time for the function to process the result.filter FeatureFilteroptionalSince 4.31 When defined, only features included in the filter are considered in the attribute and spatial statistics calculations when determining the final renderer. This is useful when a lot of variation exists in the data that could result in undesired data ranges. A common use case would be to set a filter that only includes features in the current extent of the view where the data is most likely to be viewed. Currently, only geometry filters with an
intersects
spatial relationship are supported. All other filter types (includingwhere
) are ignored.forBinning BooleanoptionalIndicates whether the generated renderer is for a binning visualization.
signal AbortSignaloptionalAllows for cancelable requests. If canceled, the promise will be rejected with an error named
AbortError
. See also AbortController.ReturnsType Description Promise<ScaleRangeResult> Resolves to an object containing the suggested min
andmax
scale for the layer.ExamplescaleRange({ layer: featureLayer, view: view }).then(function(response){ // apply the suggested scale range to the input layer featureLayer.minScale = response.minScale; featureLayer.maxScale = response.maxScale; view.map.add(featureLayer); });
Type Definitions
-
Suggested
min
andmax
scales to apply to the input layer for the scaleRange() function.