import { createRenderer, updateRenderer } from "@arcgis/core/smartMapping/renderers/heatmap.js";const { createRenderer, updateRenderer } = await $arcgis.import("@arcgis/core/smartMapping/renderers/heatmap.js");- Since
- ArcGIS Maps SDK for JavaScript 4.11
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.
Functions
createRenderer
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 optional field 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.
- Signature
-
createRenderer (parameters: HeatmapRendererParameters): Promise<HeatmapRendererResult>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameters | Input parameters for generating a heatmap visualization based on data returned from a given field. | |
- Returns
- Promise<HeatmapRendererResult>
Resolves to an instance of HeatmapRendererResult.
Example
let 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 layerheatmapRendererCreator.createRenderer(heatmapParams) .then(function(response){ earthquakeLayer.renderer = response.renderer; }); updateRenderer
- Since
- ArcGIS Maps SDK for JavaScript 4.25
Allows you to update the HeatmapRenderer.colorStops of a HeatmapRenderer with opacity, making the low density areas of the heat map to fade out.
- Signature
-
updateRenderer (parameters: UpdateHeatmapRendererParameters): HeatmapRenderer
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameters | Input parameters for updating a heatmap renderer with a given fadeRatio. | |
- Returns
- HeatmapRenderer
The updated HeatmapRenderer.
Example
const renderer = heatmapRendererCreator.updateRenderer({ renderer: layer.renderer fadeRatio: 0.7});layer.renderer = renderer;Type definitions
HeatmapRendererParameters
- Supertypes
- AbortOptions
layer
- Type
- Exclude<SupportedLayer, ImageryLayer | KnowledgeGraphSublayer | PointCloudLayer> | null | undefined
The point layer for which the visualization is generated. When a client-side layer type is provided, attribute statistics are calculated only from features in the view's extent. When a server-side layer type is provided, the statistics are calculated from the entire layer.
radius
The HeatmapRenderer.radius in points that determines the area of influence of each point. A higher radius indicates points have more influence on surrounding points.
- Default value
- 18
minRatio
The minimum HeatmapColorStop.ratio used in the HeatmapRenderer.colorStops of the output renderer.
- Default value
- 0.01
maxRatio
The maximum HeatmapColorStop.ratio used in the HeatmapRenderer.colorStops of the output renderer.
- Default value
- 1
filter
- Type
- FeatureFilter | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 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 (including where) are ignored.
statistics
- Type
- HeatmapStatisticsResult | null | undefined
A 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.
heatmapScheme
- Type
- HeatmapScheme | null | undefined
In 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.
view
- Type
- MapViewOrSceneView | null | undefined
The view instance in which the visualization will be rendered.
HeatmapRendererResult
The result object of the createRenderer() method. See the table below for details of each property.
renderer
- Type
- 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.
defaultValuesUsed
- Type
- boolean
Indicates 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.
basemapTheme
- Type
- BasemapTheme | null | undefined
Indicates whether the average color of the input view's basemap is light or dark.