Intro to CIMSymbol

This sample demonstrates how to style Point graphics on GraphicsLayer with CIMSymbol.

The app uses SketchViewModel to allow users to add new Graphics. Users could choose to use number or letter to represent the new Graphics by choosing the corresponding tool from the top-right toolbar. The following snippet shows how graphics are added to the map.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// called when sketchViewModel's create-complete event is fired.
function addGraphic(event) {
  if (event.state === "complete") {
    const cimSymbol = {
      type: "cim",
      // get JSON data defining CIMSymbolReference
      data: getCIMSymbolData()
    };
    graphicsLayer.remove(event.graphic);
    const newGraphic = new Graphic({
      geometry: event.graphic.geometry,
      attributes: {
        // used to define the text string in the symbol
        text: pointType === "number" ? String(numberIndex++) : String.fromCharCode(64 + letterIndex++)
      },
      symbol: cimSymbol
    });
    graphicsLayer.add(newGraphic);
    sketchViewModel.create("point");
  }
}

The CIMSymbol uses a PrimitiveOverride to update the value of the textString property based on the text attribute of the graphic.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  ...
  type: "CIMSymbolReference",
  primitiveOverrides: [
    {
      type: "CIMPrimitiveOverride",
      // primitiveName must match the primitiveName on the symbol layer or
      //   marker graphic that contains the property you want to override
      primitiveName: "textGraphic",
      propertyName: "TextString", // name of the property to override
      valueExpressionInfo: {
        type: "CIMExpressionInfo",
        title: "Custom",
        expression: "$feature.text",
        returnType: "Default"
      }
    }
  ],
  ...
Image preview of related sample CIMSymbol lines and polygons

CIMSymbol lines and polygons

Learn how to create CIM line and polygon symbols.

Image preview of related sample Arrows along a line

Arrows along a line

Use a CIMSymbol to draw a line with arrow markers at a fixed distance

Image preview of related sample Adjust marker placement in polygon symbols

Adjust marker placement in polygon symbols

Draw symbols in a map and adjust the CIMSymbol properties such as color, size, and marker placement.

Image preview of related sample Gridded proportional symbols

Gridded proportional symbols

Use primitive overrides to adjust CIMSymbol properties based on an attribute value

Symbol Builder

Symbol Builder application provides a UI for creating any symbol

CIMSymbol

Read the API Reference for more information.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.