useCodedValues property not working in LabelClass API 4.18

571
2
02-15-2021 10:30 AM
AhmadLibda
New Contributor III

I am trying to add a label to a featureLayer using LabelClass. The field I wish to display as a label called mun_name is of type "short" and is linked to a domain. The documentation states that setting useCodedValues to True will make the API use the domain names for labelling instead of the actual numbers (codes) stored in the field, but it still showing numbers on the map.
This is the code:

 

const mun = new FeatureLayer({
 url: `${API_URL}/rest/services/public/All/MapServer/0`,
 outFields: ["*"],
 labelingInfo: {
  labelExpressionInfo: {
    expression: "$feature.mun_name",
  },
  symbol: {
    type: "text",
    symbolLayers: [
      {
        type: "text",
        material: { color: "black" },
        halo: {
          color: "yellow",
          size: 0.4,
        },
        size: 14,
      },
    ],
  },
  useCodedValues: true,
}
})

 

Ps: The domain values work nicely when displaying that field in the layer's popup. The problem appears only when trying to use that field as a label using LabelClass. I also tried setting useCodedValues to both True, False and removing it.

 
0 Kudos
2 Replies
Andy_Morgan
New Contributor III

I'm having the same problem. The feature layer is only labeling with the code (abbreviation), not the full description, from the domain. I tried useCodedValues = true with version 4.20 and much older versions of the 4.x API. Nothing works, although it does work with MapImageLayer sublayers.

const labelClassWaterLine = {
labelPlacement: "above-center",
labelExpressionInfo: {
  expression: "$feature.PIPEMATERIAL + TextFormatting.NewLine + 
  $feature.EXPOSURETYPE"
},
useCodedValues: true,
symbol: {
  type: "text", 
  color: "red",
  haloSize: 2,
  haloColor: "white"
  }
};

 

0 Kudos
KoltWright
New Contributor

I don't know if you still have this issue or still need it solved, but I was able to this issue by using the labelExpression attribute and the useCodedValues to true.

KoltWright_0-1645137095893.png

 

 

 

0 Kudos