LabelExpressionInfo not honoring where clause

6545
23
07-14-2015 01:20 PM
DavidColey
Frequent Contributor

Hello-

So I'm trying to override the default feature layer labels, but the where clause isn't being honored.  For my map constructor options:

showLabels : true

My LabelingInfo:

var labelArray = [
  {
  labelPlacement: "esriServerPointLabelPlacementAboveRight",
  labelExpression: "[AddNumber]",
  symbol: {
    type: "esriTS",
      color: [255,0,0,255], //[38,115,0,255],
      font: {
      family: "Arial",
      size: 9,
      style: "italic",
      weight: "bold",
      decoration: "none",
    }
    },
    minScale: 2401,
    maxScale: 0,
    where: "AddressStatus LIKE 'A%'"
  }
  ];
  console.log(labelArray);

and finally for the feature layer:

lyrAddresses.setLabelingInfo(labelArray);

All of the other constructor options for the labelng info are being honored, but wheneverI try to invoke the where clause, none of the points will label-

Thanks

David

Tags (3)
0 Kudos
23 Replies
Robertvan_Gilst
New Contributor III

Hi Ujjwal,

Just tried the sandbox and changed the json variable to, as in my previous reply where I had a problem:

 var json = {
    "labelExpressionInfo": {"value": "{STATE_NAME}"},
    "where": "STATE_NAME = 'Texas'"
 };


This works fine now, and only shows a label for Texas. So maybe you have to test your SQL expression in the REST endpoint of the service your using, just to make sure it valid SQL.

Robert

UjjwalNigam
New Contributor III

Hi Robert,

Single word values work, try using "South Dakota" and you'll see what I

mean.

Other SQL expressions like LIKE, % also seem to fail.

Regards

Ujjwal

0 Kudos
Robertvan_Gilst
New Contributor III

I can see your point.

It seems to work in 4 though, but that probably will not help you...

0 Kudos
UjjwalNigam
New Contributor III

ESRI has released a new #arcade labeling engine which is still at early stages of development. Plus, there are functional differences between 3.x & 4.x versions of the Javascript API. As of now, #arcade does not support a lot of basic labeling features like LIKE queries, multi-line labels etc. Concatenation is also quite tricky though there is a CONCATENATE function available.

A workaround could be to apply the definition expression on the layer and then label the filtered out features.

0 Kudos