<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>CIMSymbol lines and polygons | 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>
<arcgis-map item-id="fedce1e9063c4354b7d4f3a887855e76">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-home slot="top-left"></arcgis-home>
expand-tooltip="Edit the CIMPointSymbol"
<div id="symbolControls">
<calcite-label>Size</calcite-label>
label-handles></calcite-slider>
<calcite-label>Rotation</calcite-label>
label-handles></calcite-slider>
const [CIMSymbol, WebStyleSymbol, cimSymbolUtils] = await $arcgis.import([
"@arcgis/core/symbols/CIMSymbol.js",
"@arcgis/core/symbols/WebStyleSymbol.js",
"@arcgis/core/symbols/support/cimSymbolUtils.js",
const viewElement = document.querySelector("arcgis-map");
// wait for the view to be ready
await viewElement.viewOnReady();
const map = viewElement.map;
//-------------------------------------------------------------
// Get layers from the map and define symbology
//-------------------------------------------------------------
const trailheads = map.layers.find((layer) => {
return layer.title === "Trailheads";
symbol: new WebStyleSymbol({
name: "trail", // trailhead symbol
styleName: "Esri2DPointSymbolsStyle",
const rimTrail = map.layers.find((layer) => {
return layer.title === "Tahoe Rim Trail";
type: "CIMSymbolReference",
// white dashed layer at center of the line
enable: true, // must be set to true in order for the symbol layer to be visible
type: "CIMGeometricEffectDashes",
dashTemplate: [2, 2], // width of dashes and spacing between the dashes
lineDashEnding: "NoConstraint",
controlPointEnding: "NoConstraint",
color: [255, 255, 255, 255],
// lighter green line layer that surrounds the dashes
color: [56, 168, 0, 255],
// darker green outline around the line symbol
color: [0, 115, 76, 255],
const lakeBoundary = map.layers.find((layer) => {
return layer.title === "Lake Tahoe Boundary";
lakeBoundary.renderer = {
type: "CIMSymbolReference",
type: "CIMPolygonSymbol",
// solid stroke for the polygon outline
color: [0, 76, 115, 255],
// gradient fill from blue -> white for polygon fill
type: "CIMLinearContinuousColorRamp",
fromColor: [0, 76, 115, 255],
toColor: [255, 255, 255, 255],
gradientMethod: "Circular",
gradientSizeUnits: "Relative",
gradientType: "Continuous",
//-------------------------------------------------------------
// Use CIMSymbolUtils to edit the size & rotation of the symbol
//-------------------------------------------------------------
// convert WebStyleSymbol -> CIMSymbol
trailheads.renderer.symbol.fetchSymbol().then((cimSymbol) => {
trailheads.renderer.symbol = cimSymbol;
const sizeSlider = document.getElementById("sizeSlider");
sizeSlider.addEventListener("calciteSliderChange", (event) => {
const value = event.target.value;
const newSymbol = trailheads.renderer.symbol.clone(); // clone the current symbol
// use CIM util function to scale the symbol to a new size
cimSymbolUtils.scaleCIMSymbolTo(newSymbol, value);
// update the renderer to the new symbol
const rotationSlider = document.getElementById("rotationSlider");
rotationSlider.addEventListener("calciteSliderChange", (event) => {
const value = event.target.value;
const newSymbol = trailheads.renderer.symbol.clone(); // clone the current symbol
// use CIM util function to change the rotation of the symbol
cimSymbolUtils.applyCIMSymbolRotation(newSymbol, value);
// update the renderer to the new symbol