Select to view content in your preferred language

Rendering a list of webstyle symbols using unique value renderer in ESRI editor

560
1
09-20-2023 11:49 PM
KarthikeyanShanmugam
Emerging Contributor

Hello,

We are using the editor widget in ESRI for the crud operations of the symbols. I was able to succesfully render a webstyle symbol using the simple renderer. 

    const layer = new FeatureLayer({
      source: graphics,
      // renderer,
      renderer:{ 
        type: "simple",
        symbol: {
          type: "web-style",  // autocasts as new SimpleFillSymbol()
          styleName: "Esri2DPointSymbolsStyle",
          name: "atm"
        }
      },
      objectIdField: "ObjectID"
    })

 

The use case which I currently have is to render more than one webstyle symbol in the editor. Since the simple renderer does not accept array of symbols , Is there any renderer which I can use to display the symbols on the editor.

I was trying it out with unique-renderer , but it does not seem to be working. Please find the screenshot attached

KarthikeyanShanmugam_0-1695278649970.png

Thank you

0 Kudos
1 Reply
JeffreyThompson2
MVP Regular Contributor

The unique-value renderer should do what you want. If it didn't work for you, it's likely you have some sort of syntax error. Here is a code example.

const hwyRenderer = {
          type: "unique-value",
          legendOptions: {
            title: "Freeway type"
          },
          field: "RTTYP",
          uniqueValueInfos: [{
            value: "S",
            label: "State highway",
            symbol: {
              type: "simple-line",
              color: "#e6d800",
              width: "6px",
              style: "solid"
            }
          }, {
            value: "I",
            label: "Interstate",
            symbol: {
              type: "simple-line",
              color: "#e60049",
              width: "6px",
              style: "solid"
            }
          }, {
            value: "U",
            label: "US Highway",
            symbol: {
              type: "simple-line",
              color: "#9b19f5",
              width: "6px",
              style: "solid"
            }
          }]
        };

https://developers.arcgis.com/javascript/latest/visualization/data-driven-styles/unique-types/#categ...

GIS Developer
City of Arlington, Texas
0 Kudos