<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Visualize points in a scene with a heatmap | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
transform: translate(-50%, -50%);
<arcgis-scene basemap="satellite" ground="world-elevation">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
<arcgis-compass slot="top-left"> </arcgis-compass>
<arcgis-legend slot="bottom-left"></arcgis-legend>
<calcite-button appearance="outline-fill" color="blue" id="toggleModeButton"
>Static reference scale</calcite-button
const [IntegratedMeshLayer, FeatureLayer, HeatmapRenderer] = await $arcgis.import([
"@arcgis/core/layers/IntegratedMeshLayer.js",
"@arcgis/core/layers/FeatureLayer.js",
"@arcgis/core/renderers/HeatmapRenderer.js",
/*****************************************************************
* Get a reference to the HTML elements
*****************************************************************/
const viewElement = document.querySelector("arcgis-scene");
const legend = document.querySelector("arcgis-legend");
const toggleModeButton = document.getElementById("toggleModeButton");
/*****************************************************************
* Create the mesh layer with the city
*****************************************************************/
const meshLayer = new IntegratedMeshLayer({
url: "https://tiles-eu1.arcgis.com/7cCya5lpv5CmFJHv/arcgis/rest/services/Munich_3D_Mesh_City_Mapper_2_SURE_43/SceneServer",
/*****************************************************************
* Prepare the heatmap renderer and create the feature layer with incidents
*****************************************************************/
{ ratio: 0 / 12, color: "rgba(25, 43, 51, 0.6)" },
{ ratio: 2 / 12, color: "rgba(30, 140, 160, 1)" },
{ ratio: 3 / 12, color: "rgba(58, 165, 140, 1)" },
{ ratio: 4 / 12, color: "rgba(64, 184, 156, 1)" },
{ ratio: 5 / 12, color: "rgba(68, 199, 168, 1)" },
{ ratio: 6 / 12, color: "rgba(73, 214, 181, 1)" },
{ ratio: 7 / 12, color: "rgba(78, 230, 194, 1)" },
{ ratio: 8 / 12, color: "rgba(83, 245, 207, 1)" },
{ ratio: 9 / 12, color: "rgba(85, 250, 211, 1)" },
{ ratio: 10 / 12, color: "rgba(102, 255, 219, 1)" },
{ ratio: 11 / 12, color: "rgba(121, 237, 210, 1)" },
{ ratio: 12 / 12, color: "rgba(158, 255, 233, 1)" },
const heatmapRenderer = new HeatmapRenderer({
// autocasts as new PopupTemplate()
title: "Traffic incident #{OBJECTID}",
content: "<p> {UJAHR} / {UMONAT} </p>", // Show year and month
const incidentsLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/TrafficAccidentsGermany2019/FeatureServer",
popupTemplate: popupTemplate,
renderer: heatmapRenderer,
/*****************************************************************
* Setup the Scene component with layers
*****************************************************************/
// Wait for the view to initialize
await viewElement.viewOnReady();
viewElement.map.addMany([meshLayer, incidentsLayer]);
// Set the camera to focus on Munich, Germany
heading: 3.283715534412251,
/*****************************************************************
* Allow to toggle between fixed reference scale (where radius
* remains constant in real world size) and visualization where
* the radius remains constant in screen size (in points).
*****************************************************************/
function toggleHeatmapMode() {
heatmapRenderer.referenceScale = viewElement.scale;
heatmapRenderer.referenceScale = null;
addStaticScale: "Static reference scale",
removeScale: "Remove reference scale",
toggleModeButton.textContent = promptText.addStaticScale;
toggleModeButton.addEventListener("click", () => {
fixToScale = !fixToScale;
toggleModeButton.textContent = promptText.removeScale;
toggleModeButton.textContent = promptText.addStaticScale;
/*****************************************************************
* Customize the Legend component
*****************************************************************/
await legend.componentOnReady();
title: "Number of traffic incidents",