Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
    <title>CIM Symbol issue</title>

    <style>
        html,
        body,
        #viewDiv {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
    </style>

    <link rel="stylesheet" href="https://js.arcgis.com/4.20/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.20/"></script>

    <script>
        // Only required for ease of debugging, not to make it to prod code...
        globals = {};
        require(["esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer", "esri/symbols/CIMSymbol"], function (Map, MapView, FeatureLayer, CIMSymbol) {

    
            const cimJson = {
  "type": "CIMPointSymbol",
  "symbolLayers": [
    {
      "type": "CIMVectorMarker",
      "enable": true,
      "size": 10,
      "colorLocked": true,
      "anchorPointUnits": "Relative",
      "frame": {
        "xmin": -5,
        "ymin": -5,
        "xmax": 5,
        "ymax": 5
      },
      "markerGraphics": [
        {
          "type": "CIMMarkerGraphic",
          "geometry": {
            "x": 0,
            "y": 0
          },
          "symbol": {
            "type": "CIMTextSymbol",
            "fontFamilyName": "Arial",
            "fontStyleName": "Bold",
            "height": 10,
            "horizontalAlignment": "Center",
            "offsetX": 0,
            "offsetY": 5.5,
            "symbol": {
              "type": "CIMPolygonSymbol",
              "symbolLayers": [
                {
                  "type": "CIMSolidFill",
                  "enable": true,
                  "color": [
                    214,
                    41,
                    41,
                    255
                  ]
                }
              ]
            },
            "verticalAlignment": "Center",
            "font": {
              "family": "Arial",
              "decoration": "none",
              "style": "normal",
              "weight": "bold"
            }
          },
          "textString": "Please don't cut me off"
        }
      ],
      "scaleSymbolsProportionally": true,
      "respectFrame": true
    },
    {
      "type": "CIMVectorMarker",
      "enable": true,
      "anchorPointUnits": "Relative",
      "dominantSizeAxis3D": "Y",
      "size": 67,
      "billboardMode3D": "FaceNearPlane",
      "frame": {
        "xmin": 0,
        "ymin": 0,
        "xmax": 28,
        "ymax": 17
      },
      "markerGraphics": [
        {
          "type": "CIMMarkerGraphic",
          "geometry": {
            "rings": [
              [
                [
                  0,
                  17
                ],
                [
                  28,
                  17
                ],
                [
                  28,
                  0
                ],
                [
                  0,
                  0
                ],
                [
                  0,
                  17
                ]
              ]
            ]
          },
          "symbol": {
            "type": "CIMPolygonSymbol",
            "symbolLayers": [
              {
                "type": "CIMSolidStroke",
                "enable": true,
                "capStyle": "Round",
                "joinStyle": "Round",
                "lineStyle3D": "Strip",
                "miterLimit": 10,
                "width": 1,
                "color": [
                  0,
                  0,
                  0,
                  255
                ]
              },
              {
                "type": "CIMSolidFill",
                "enable": true,
                "color": [
                  255,
                  255,
                  255,
                  255
                ]
              }
            ]
          }
        }
      ],
      "scaleSymbolsProportionally": true,
      "respectFrame": true
    }
  ]
}
            const cimSymbol = new CIMSymbol({
                data: {
                    type: "CIMSymbolReference",
                    symbol: cimJson,
                }
            });
            const createCalloutRenderer = function (features) {
                var renderer = {
                    type: "unique-value", // autocasts as new UniqueValueRenderer()
                    field: "OBJECTID",
                    uniqueValueInfos: []
                };
                features.forEach((feature) => {
                    renderer.uniqueValueInfos.push({
                        value: feature.attributes["OBJECTID"],
                        symbol: cimSymbol
                    })
                });
                return renderer
            };
            // Construct the layer and add it to the map
            const layer = new FeatureLayer({
                url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/weather_stations_010417/FeatureServer/0",
                //renderer: renderer,
                definitionExpression: "COUNTRY = 'Australia'",
                opacity: 1
            });
            bob = layer;
            const map = new Map({
                basemap: "streets",
                layers: [layer]
            });
            const view = new MapView({
                container: "viewDiv",
                map: map,
                extent: {
                    spatialReference: {
                        wkid: 3857
                    },
                    xmin: -28124636,
                    ymin: -5440569,
                    xmax: -22902459,
                    ymax: -788304
                },
                highlightOptions: {
                    color: "blue",
                    haloColor: "blue",
                    haloOpacity: 0.4,
                    fillOpacity: 0.001
                }
            });
            view.when(() => {
                globals.map = map;
                globals.view = view;
                view.whenLayerView(layer).then((layerView) => {
                    // highlighted feature
                    var highlight, currentFeatureObjectId;
                    // Build the renderer
                    layer.createQuery();
                    layer.queryFeatures().then((featureSet) => {
                        // featureSet.features.forEach((feature) => {
                        //     console.log(feature);
                        // });
                        //layer.renderer = renderer;
                        layer.renderer = createCalloutRenderer(featureSet.features);
                        //layerView.highlight(featureSet.features[0])
                    });
                    // Handle mouse events
                    view.on("pointer-move", mouseEventsHandler);
                    view.on("pointer-down", mouseEventsHandler);

                    function mouseEventsHandler(events) {
                        const opts = {
                            include: layer
                        }
                        // the hitTest() checks to see if any graphics from the hurricanesLayer
                        // intersect the x, y coordinates of the pointer
                        view.hitTest(event, opts).then((response) => {
                            if (response.results.length) {
                                if (response.results[0].graphic.attributes.OBJECTID !== currentFeatureObjectId) {
                                    if (highlight && currentFeatureObjectId) {
                                        highlight.remove();
                                    }
                                    currentFeatureObjectId = response.results[0].graphic.attributes.OBJECTID;
                                    highlight = layerView.highlight(response.results[0].graphic);
                                }
                            } else if (highlight && currentFeatureObjectId) {
                                currentFeatureObjectId = null;
                                highlight.remove();
                            }
                            //console.log(response);
                        });
                    }
                });
            });
        });
    </script>
</head>

<body>
    <div id="viewDiv"></div>
</body>

</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Inter:wght@500&display=swap');
              
            
!

JS

              
                
              
            
!
999px

Console