require(["esri/smartMapping/renderers/heatmap"], (heatmapRendererCreator) => { /* code goes here */ });
import * as heatmapRendererCreator from "@arcgis/core/smartMapping/renderers/heatmap.js";
esri/smartMapping/renderers/heatmap
This object contains a helper method for generating a HeatmapRenderer for a point Layer.
It is important to note that the input layer must have features available in the input view for the createRenderer() method to generate a meaningful heatmap. Otherwise, the method will fail.
Known Limitation
Only layers with point geometries are supported.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Promise<HeatmapRendererResult> | Generates a HeatmapRenderer that may be applied directly to the layer used to call this method. | heatmap | |
Allows you to update the colorStops of a HeatmapRenderer with opacity, making the low density areas of the heat map to fade out. | heatmap |
Method Details
-
createRenderer
createRenderer(params){Promise<HeatmapRendererResult>}
-
Generates a HeatmapRenderer that may be applied directly to the layer used to call this method. The renderer represents points as a continuous surface using optimal colors for the view's background.
This method should be called when at least some points are visible in the input view's extent. If no points are visible in the view, then the response will not return a useful visualization.
In most cases you will provide a
layer
,view
, and optionalfield
to generate this renderer. This is a scenario in which the statistics and the distribution of the data aren't well known and the user doesn't know what colors to use in the visualization.The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the statistics object to the
statistics
parameter to avoid making an extra call to the server.ParametersSpecificationparams ObjectInput parameters for generating a heatmap visualization based on data returned from a given field. See the table below for details of each parameter.
Specificationlayer FeatureLayer|CSVLayer|GeoJSONLayer|WFSLayer|OGCFeatureLayer|StreamLayer|OrientedImageryLayer|KnowledgeGraphSublayer|SubtypeGroupLayer|SubtypeSublayerThe point layer for which the visualization is generated.
The view instance in which the visualization will be rendered.
field StringoptionalThe name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. The value of the
field
is used as a multiplier in the heatmap, making areas with high field values hotter than areas where the features have low field values.heatmapScheme HeatmapSchemeoptionalIn authoring apps, the user may select a pre-defined heatmap scheme. Pass the scheme object to this property to avoid getting one based on the view's background.
statistics HeatmapStatisticsResultoptionalA statistics object generated from the heatmapStatistics function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server.
fadeRatio NumberoptionalDefault Value: 0.2Indicates how much to fade the lower color stops with transparency to create a fuzzy boundary on the edge of the heatmap. A value of
0
makes a discrete boundary on the lower color stop.fadeToTransparent BooleanoptionalDefault Value: trueIndicates whether the heatmap should fade its colors to transparent. When
false
, thefadeRatio
parameter is ignored.radius NumberoptionalDefault Value: 18The radius in points that determines the area of influence of each point. A higher radius indicates points have more influence on surrounding points.
minRatio NumberoptionalDefault Value: 0.01The minimum ratio used in the HeatmapRenderer.colorStops of the output renderer.
maxRatio NumberoptionalDefault Value: 1The maximum ratio used in the HeatmapRenderer.colorStops of the output renderer.
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.signal AbortSignaloptionalAllows for cancelable requests. If canceled, the promise will be rejected with an error named
AbortError
. See also AbortController.ReturnsType Description Promise<HeatmapRendererResult> Resolves to an instance of HeatmapRendererResult. Examplelet earthquakeLayer = new FeatureLayer({ // url to a point dataset }); // visualization based on field let heatmapParams = { layer: earthquakeLayer, view: view, field: "magnitude" }; // when the promise resolves, apply the renderer to the layer heatmapRendererCreator.createRenderer(heatmapParams) .then(function(response){ earthquakeLayer.renderer = response.renderer; });
-
updateRenderer
updateRenderer(params){HeatmapRenderer}
Since: ArcGIS Maps SDK for JavaScript 4.25heatmap since 4.11, updateRenderer added at 4.25. -
Allows you to update the colorStops of a HeatmapRenderer with opacity, making the low density areas of the heat map to fade out.
ParametersSpecificationparams ObjectInput parameters for updating a heatmap renderer with a given fadeRatio.
Specificationrenderer HeatmapRendererThe heatmap renderer for which to add or remove opacity.
fadeRatio NumberoptionalIndicates how much to fade the lower color stops with transparency to create a fuzzy boundary on the edge of the heatmap. A value of
0
makes a discrete boundary on the lower color stop.ReturnsType Description HeatmapRenderer The updated HeatmapRenderer. Exampleconst renderer = heatmapRendererCreator.updateRenderer({ renderer: layer.renderer fadeRatio: 0.7 }); layer.renderer = renderer;
Type Definitions
-
The result object of the createRenderer() method. See the table below for details of each property.
- Properties
-
renderer HeatmapRenderer
The renderer object configured to best match the view's background and the spread of the data. Set this on a layer's
renderer
property to update its visualization.scheme HeatmapSchemeThe color scheme used by the renderer.
defaultValuesUsed BooleanIndicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all.
statistics HeatmapStatisticsResultBasic statistics required for generating a renderer with optimal values for the given layer and view.
basemapId StringThe ID of the basemap used to determine the optimal color stops of the heatmap.
basemapTheme StringIndicates whether the average color of the input view's basemap is
light
ordark
.