Skip to content
import { getCIMSymbolSize, scaleCIMSymbolTo, getCIMSymbolColor, applyCIMSymbolColor, getCIMSymbolRotation } from "@arcgis/core/symbols/support/cimSymbolUtils.js";
Since
ArcGIS Maps SDK for JavaScript 4.16

Provides utility functions for CIMSymbols. These methods will allow you to get and set the size, color, and rotation of a CIMsymbol.

See also

Type definitions

ScaleCIMSymbolOptions

Type definition

preserveOutlineWidth

Property
Type
boolean

When true, this property will preserve the outline width of the symbol. This property will only work when scaleSymbolsProportionally is false on the symbol layer. If scaleSymbolsProportionally is true, this property will be ignored.

ApplyCIMSymbolColorOptions

Type definition

layersToColor

Property
Type
"fill" | "outline" | "fill-and-outline"

The symbol layers to apply the color to. This only applies to CIMPolygonSymbols and CIMPointSymbols with embedded polygon marker graphics. The "fill" option will only apply the color to the fill symbol layers - CIMSolidFill, CIMHatchFill, CIMPictureFill, etc. The "outline" option will only apply the color to the stroke symbol layers - like CIMSolidStroke and CIMPictureStroke. The "fill-and-outline" option will apply the color to both fill and stroke layers. The default value is "fill".

Functions

getCIMSymbolSize

Function

Returns the size of a given CIMSymbol. The size of a CIMSymbol is defined as the size of the largest symbol layer.

Signature
getCIMSymbolSize (symbol: CIMSymbol): number
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol from which to get the size.

Returns
number

Returns the size of the symbol in pixels.

scaleCIMSymbolTo

Function

Scales the largest layer of a CIMSymbol to a given size. The other symbol layers will scale accordingly.

Signature
scaleCIMSymbolTo (symbol: CIMSymbol | null | undefined, size: number, options?: ScaleCIMSymbolOptions): void
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol to scale.

size

The desired size for the symbol.

options

Options for scaling the symbol.

Returns
void

getCIMSymbolColor

Function

Returns the first color of the symbol layers in a CIMSymbol.

Known Limitations

  • Not supported on CIMGradientStroke and CIMGradientFill symbol layers.
Signature
getCIMSymbolColor (symbol: CIMSymbol): Color | null | undefined
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol from which to get the color.

Returns
Color | null | undefined

Returns the color of the CIMSymbol.

applyCIMSymbolColor

Function

Sets the color of the symbol layers of a CIMSymbol to a given value if the symbol layer is not color locked.

Known Limitations

  • Not supported on CIMGradientStroke and CIMGradientFill symbol layers.
Signature
applyCIMSymbolColor (symbol: CIMSymbol, color: Color, options?: ApplyCIMSymbolColorOptions): void
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol to set the color on.

color

The desired color value for the symbol.

options

Since 4.23 The options for setting the color of the CIMSymbol.

Returns
void

getCIMSymbolRotation

Function

Returns the rotation value of a CIMSymbol.

Signature
getCIMSymbolRotation (symbol: CIMSymbol, clockwise?: boolean): number
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol from which to get the rotation.

clockwise

Indicates whether to get the rotation value as clockwise rotation. Default is false.

Returns
number

The rotation value of the symbol in degrees.

applyCIMSymbolRotation

Function

Sets the rotation value of a CIMSymbol.

Signature
applyCIMSymbolRotation (symbol: CIMSymbol, rotation: number, clockwise?: boolean): void
Parameters
ParameterTypeDescriptionRequired
symbol

The CIMSymbol to set the rotation on.

rotation

The desired rotation of the symbol in degrees.

clockwise

Indicates whether to rotate the symbol clockwise. Default is false.

Returns
void