<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Line patterns in 3D | 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>
background-color: var(--calcite-color-foreground-1);
transform: translate(-50%, 0);
font-family: var(--calcite-font-family);
font-size: var(--calcite-font-size);
border-bottom: 1px solid var(--calcite-ui-border-1);
<arcgis-scene item-id="02b635b4926c42ddb4fa21c99305fb23" popup-disabled="">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
<arcgis-compass slot="top-left"></arcgis-compass>
<div class="legend-section">
<div class="title">Hiking paths</div>
<div class="legend-section-items">
<div class="legend-item">
<div class="symbol" id="easyHikingSymbol"></div>
<div class="legend-item-title">Easy</div>
<div class="legend-item">
<div class="symbol" id="mediumHikingSymbol"></div>
<div class="legend-item-title">Medium</div>
<div class="legend-item">
<div class="symbol" id="difficultHikingSymbol"></div>
<div class="legend-item-title">Difficult</div>
<div class="legend-item">
<div class="symbol" id="panoramaHikingSymbol"></div>
<div class="legend-item-title">Panoramic</div>
<div class="legend-section">
<div class="title">Public transport</div>
<div class="legend-section-items">
<div class="legend-item">
<div class="symbol" id="cableCarSymbol"></div>
<div class="legend-item-title">Cable cars</div>
<div class="legend-item">
<div class="symbol" id="winterServiceSymbol"></div>
<div class="legend-item-title">Winter service</div>
<div class="legend-item">
<div class="symbol" id="railwaySymbol"></div>
<div class="legend-item-title">Railway</div>
] = await $arcgis.import([
"@arcgis/core/renderers/UniqueValueRenderer.js",
"@arcgis/core/renderers/SimpleRenderer.js",
"@arcgis/core/symbols/LineSymbol3DLayer.js",
"@arcgis/core/symbols/LineSymbol3D.js",
"@arcgis/core/symbols/patterns/LineStylePattern3D.js",
"@arcgis/core/symbols/support/symbolUtils.js",
const viewElement = document.querySelector("arcgis-scene");
const cableCarsSymbol = new LineSymbol3D({
pattern: new LineStylePattern3D({
style: "solid", // Using solid for status === "open"
material: { color: [30, 30, 30] },
const winterServiceSymbol = new LineSymbol3D({
pattern: new LineStylePattern3D({
style: "long-dash", // Using a pattern for status === "winter"
material: { color: [30, 30, 30] },
const cableCarRenderer = new UniqueValueRenderer({
symbol: winterServiceSymbol,
const railwaySymbol = new LineSymbol3D({
material: { color: [30, 30, 30] },
material: { color: [240, 240, 240] },
pattern: new LineStylePattern3D({
material: { color: [30, 30, 30] },
const railwayRenderer = new SimpleRenderer({
const easyHikingPathSymbol = getHikingPathSymbol("solid", [252, 194, 1]);
const mediumHikingPathSymbol = getHikingPathSymbol("dash", [252, 194, 1]);
const difficultHikingPathSymbol = getHikingPathSymbol("dot", [252, 194, 1]);
const easyPanoramaPathSymbol = getHikingPathSymbol("solid", [250, 59, 32]);
const mediumPanoramaPathSymbol = getHikingPathSymbol("dash", [250, 59, 32]);
const difficultPanoramaPathSymbol = getHikingPathSymbol("dot", [250, 59, 32]);
const hikingPathRenderer = new UniqueValueRenderer({
symbol: easyHikingPathSymbol,
symbol: mediumHikingPathSymbol,
symbol: difficultHikingPathSymbol,
value: "easy, panoramic",
symbol: easyPanoramaPathSymbol,
value: "medium, panoramic",
symbol: mediumPanoramaPathSymbol,
value: "difficult, panoramic",
symbol: difficultPanoramaPathSymbol,
await viewElement.viewOnReady();
const cableCarLayer = viewElement.map.allLayers.find((layer) => layer.title === "CableCars");
const railwayLayer = viewElement.map.allLayers.find((layer) => layer.title === "Railway");
const hikingPathLayer = viewElement.map.allLayers.find(
(layer) => layer.title === "HikingPaths",
cableCarLayer.elevationInfo = {
// Using feature line's absolute z-values for the cable cars.
cableCarLayer.renderer = cableCarRenderer;
railwayLayer.elevationInfo = {
railwayLayer.renderer = railwayRenderer;
hikingPathLayer.elevationInfo = {
hikingPathLayer.renderer = hikingPathRenderer;
function getHikingPathSymbol(patternStyle, color) {
// Each line is rendered with two symbol layers: an opaque line and a semi-transparent background of the same color underneath it.
const patternColor = new Color(color);
const backgroundColor = new Color(color);
// Adding an alpha value to make the background transparent.
return new LineSymbol3D({
// If no pattern is specified, line is rendered as solid.
material: { color: backgroundColor },
size: patternStyle === "dot" ? "3px" : "2px",
pattern: new LineStylePattern3D({
// Using pattern to mark difficulty
material: { color: patternColor },
size: patternStyle === "dot" ? "3px" : "1.6px",
// Create a custom legend
addLegendSymbol("easyHikingSymbol", easyHikingPathSymbol);
addLegendSymbol("mediumHikingSymbol", mediumHikingPathSymbol);
addLegendSymbol("difficultHikingSymbol", difficultHikingPathSymbol);
addLegendSymbol("panoramaHikingSymbol", easyPanoramaPathSymbol);
addLegendSymbol("cableCarSymbol", cableCarsSymbol);
addLegendSymbol("winterServiceSymbol", winterServiceSymbol);
addLegendSymbol("railwaySymbol", railwaySymbol);
function addLegendSymbol(divId, symbol) {
const node = document.getElementById(divId);
symbolUtils.renderPreviewHTML(symbol, { node });