Select to view content in your preferred language

Web Scene Feaature's Symbology not changing

1079
3
Jump to solution
12-31-2021 04:16 AM
AroopChakraborty1
Occasional Contributor

I am adding the feature layer, which is a part of a Web Scene in ArcGIS API for JavaScript 4.22 and giving the symbology but it is not coming and all layers are coming in same default color how to resolve this issue. Any suggestions are welcome.

 

The sample code:

const buffer20m = {
type: "polygon", // autocasts as new SimpleRenderer()
symbol: {
type: "simple-fill",
color: [151, 151, 204, 0.5],
style: "solid",
outline: {
color: "white",
width: 1
}
}
};


const buffer_20m = new FeatureLayer({
url: "https://********/*********/arcgis/rest/services/Buffer*****_Electric_Transmission_Lines_shp1/Feature...,
renderer: buffer20m,
outFields: ["*"],
});

I have also added one screenshot as attachment

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

When autocasting the SimpleRenderer you must pass in the appropriate 'type' parameter, which the doc tells us  for a SimpleRenderer the value is 'simple'.  Maybe this will work:

const buffer20m = {
  type: "simple",
  symbol: {
    type: "simple-fill",
    color: [151, 151, 204, 0.5],
    style: "solid",
    outline: {
      color: "white",
      width: 1
    }
  }
};

 

View solution in original post

3 Replies
JohnGrayson
Esri Regular Contributor

When autocasting the SimpleRenderer you must pass in the appropriate 'type' parameter, which the doc tells us  for a SimpleRenderer the value is 'simple'.  Maybe this will work:

const buffer20m = {
  type: "simple",
  symbol: {
    type: "simple-fill",
    color: [151, 151, 204, 0.5],
    style: "solid",
    outline: {
      color: "white",
      width: 1
    }
  }
};

 

AroopChakraborty1
Occasional Contributor

Thank You John & happy New Year, 

You're a saviour, the code is running and layer is getting rendered correctly.

John these layers participate in a map scene. I have a 3d line which is drawn using an offset, the layer is displayed but the problem of rendering persists.

const ET_Line = {
type: "line-3d", // autocasts as new LineSymbol3d()

label: "line-height",
visualVariables: [
{
type: "size",
axis: "height", // tree height


},
{
type: "color",
// Carbon storage
stops: [
{
value: 0,
color: "#000000"
}, // features with zero carbon
{
value: 40,
color: "#000000"
} // features with 800 carbon
],
legendOptions: {
title: "Height in Meter"
}
}
]
};

0 Kudos
JohnGrayson
Esri Regular Contributor

Since this is a different issue from the original question which has already been answered, creating a new entry is probably the best approach.  Also, having a CodePen or similar showing us what you have tried is always the best way to get appropriate assistance.  In the code snippet above, you are not telling the 'size' VisualVariable where to get values from; try using a field or valueExpression.  Check out the various examples in the SizeVariable doc.

0 Kudos