LabelClass with where clause

2397
1
02-23-2016 04:36 AM
AnasKanaan
New Contributor

hey!

i am wondering if somebody has done some sort of test regarding labelclass with where clause

i have already used the sandbox mentioned in the documentation with the following where clause code as mentioned in the documentation as well

labelClass.where = "areaname='Redlands'"

ArcGIS API for JavaScript Sandbox

i changed areaname to STATE_NAME and replaced Redlands to Texas for example and the filtering does not work at all

i just get no labels att all

i have played a little with the syntax and get it working with the following code

labelClass.where = "'STATE_NAME' = Utah";

i have also another question regarding the use of LIKE statement instead of equal

is there somebody who has an idea who can we do this for example

labelClass.where = "'STATE_NAME' like '%U'";

0 Kudos
1 Reply
DavidChambers1
New Contributor III

Hi Anas Kanaan​ it looks like there is a current issue with the where clause and the labelClass and I have experienced the same behavior as well. From my experience, if you need to use custom logic with labels in JavaScript it's easier to:

1. Publish Annotation from ArcMap

2. Use a TextSymbol instead of a LabelClass.  Go the service and get the labels you need, then consume them with a TextSymbol.  This gives you more fine-grained control.