This sample shows how to apply predefined line styles and custom dash templates to polylines. Patterns provide an additional dimension when visualizing line data, especially in situations where features of the same color need to be differentiated.

In this example, we highlight a beautiful panoramic hiking trail in an Alpine valley and use line patterns to communicate the difficulty of sections along the trail. We also use patterns to distinguish cable car routes from railway lines and show their different types.

The pattern style is set on the LineSymbol3DLayer on a LineSymbol3D:

const symbol = {
type: "line-3d", // autocasts as new LineSymbol3D()
symbolLayers: [
{
type: "line", // autocasts as new LineSymbol3DLayer()
size: "2px",
material: { color: "black" },
pattern: {
type: "style", // autocasts as new LineStylePattern3D()
style: "long-dash-dot-dot",
},
},
],
};

To define a custom repeating sequence of dashes and gaps, use a LineTemplatePattern3D. The dashTemplate values alternate between dash and gap lengths, starting with a dash. Each value is a multiple of the symbol layer’s line width. For example, [0.2, 1] creates short dashes separated by gaps of one line width. You can combine a patterned layer with a solid layer to create a multi-layer line symbol:

const customDashSymbol = {
type: "line-3d", // autocasts as new LineSymbol3D()
symbolLayers: [
{
type: "line", // autocasts as new LineSymbol3DLayer()
pattern: {
type: "template", // autocasts as new LineTemplatePattern3D()
dashTemplate: [0.2, 1],
},
material: { color: [35, 35, 35] },
size: "5.5",
},
{
type: "line", // autocasts as new LineSymbol3DLayer()
material: { color: [35, 35, 35] },
size: "2",
},
],
};
3DPolylinepatternstyleLineStylePattern3DLineTemplatePattern3DviewOnReadyarcgis-compassarcgis-navigation-togglearcgis-scenearcgis-zoommap-components