This sample demonstrates how to create a scale-dependent visualization with a HeatmapRenderer and a SimpleRenderer.

A HeatmapRenderer is ideal for visualizing large, dense point datasets, particularly those that have lots of overlapping points. However, the heatmap is only effective at certain scales. It particularly tends to fail to convey useful information at large scales.

The sample defines the heatmap’s colors, radius, and density range. You can set up a watch on the scale property and set a scale threshold so the layer’s renderer can switch from a heatmap to discrete marker symbols as the user zooms to large scales.

Switch between heatmap renderer and simple renderer at specific scale
const heatmapRenderer = {
type: "heatmap",
radius: 15.776471,
minDensity: 0,
maxDensity: 0.0330866,
colorStops: [
{ color: "rgba(133, 193, 200, 0)", ratio: 0 },
{ color: "rgba(133, 193, 200, 0)", ratio: 0.01 },
{ color: "#85c1c8", ratio: 0.01 },
{ color: "#90a1be", ratio: 0.085348 },
{ color: "#9c8184", ratio: 0.160697 },
{ color: "#a761aa", ratio: 0.236045 },
{ color: "#af4980", ratio: 0.311393 },
{ color: "#b83055", ratio: 0.386741 },
{ color: "#c0182a", ratio: 0.46209 },
{ color: "#c80000", ratio: 0.537438 },
{ color: "#d33300", ratio: 0.612786 },
{ color: "#de6600", ratio: 0.688135 },
{ color: "#e99900", ratio: 0.763483 },
{ color: "#f4cc00", ratio: 0.838831 },
{ color: "#ffff00", ratio: 0.91418 },
],
};
// This simple renderer render all points as simple markers
const simpleRenderer = {
type: "simple",
symbol: {
type: "simple-marker",
color: "#c80000",
size: 4.5,
outline: {
color: [0, 0, 0, 0.75],
width: 1.5,
},
},
};
layer.renderer = heatmapRenderer;
viewElement.map = new Map({
basemap: "topo-vector",
layers: [layer],
});
await viewElement.viewOnReady();
viewElement.constraints.minScale = 1155582;
// When the scale is larger than 1:72,224 (zoomed in past that scale),
// then switch from a heatmap renderer to a simple renderer. When zoomed
// out beyond that scale, switch back to the heatmap renderer
reactiveUtils.watch(
() => viewElement.scale,
(scale) => {
layer.renderer = scale <= 72224 ? simpleRenderer : heatmapRenderer;
},
{ initial: true },
);

This will create a more ideal visualization at large and small scales.

2DheatmapHeatmapRendererscaleSimpleRendererreactiveUtilsviewOnReadyarcgis-expandarcgis-legendarcgis-maparcgis-popuparcgis-zoommap-components