This works:
where: "status = PENDING"
I am trying to apply a condition to my LabelClass as follows... the where clause does not seem to be working
labelClass = {
symbol: {
type: 'text', // autocasts as new TextSymbol()
color: 'black',
font: { // autocast as new Font()
family: 'Material Icons',
}
},
labelPlacement: 'center-center',
labelExpressionInfo: {
expression: '"\u2714"'
},
where: "status in ('PENDING', 'DRY_RUN')"
};
What happens if you go long form?
status = 'PENDING' OR status = 'DRY_RUN'
Yes, I tried that also. In fact, I've tried most every variation I could think of:
where: "status = PENDING or status = DRY_RUN"
where: "status = PENDING OR status = DRY_RUN"
where: "status = PENDING || status = DRY_RUN"
where: "status in ('PENDING', 'DRY_RUN')"
where: "status IN ('PENDING', 'DRY_RUN')"
where: "status IN (PENDING, DRY_RUN)"
where: "status = 'PENDING' or status = 'DRY_RUN'"
where: "status = PENDING |DRY_RUN"
where: "status in PENDING |DRY_RUN"
Try
"status == 'PENDING' || status == 'DRY_RUN'"
"(status = 'PENDING') || (status = 'DRY_RUN')"
There are some strange things going on with the "where" expression. Looking at this sample (and adding in your labelExpressionInfo), I've tried a few different versions. It looks like it doesn't like spaces in the clause.
where: "MARKER_ACTIVITY IN ('Picnicking','Sledding/Tubing')" - returns check marks
where: "MARKER_ACTIVITY IN ('Picnicking', 'Sledding/Tubing')" - doesn't return check marks
where: "(MARKER_ACTIVITY = 'Sledding/Tubing') or (MARKER_ACTIVITY = 'Picnicking')" - doesn't return check marks
where: "(MARKER_ACTIVITY = 'Sledding/Tubing')||(MARKER_ACTIVITY = 'Picnicking')" - doesn't return check marks
where: "(MARKER_ACTIVITY = 'Sledding/Tubing') || (MARKER_ACTIVITY = 'Picnicking')" - doesn't return check marks
where: "MARKER_ACTIVITY = 'Sledding/Tubing'" - returns check marks
where: "MARKER_ACTIVITY = 'Intermediate Parent Group'" - doesn't return check marks
where: "MARKER_ACTIVITY like 'Intermediate%'" - returns check marks
Hi Ken - I got this to work ok in CodePen:
labelExpressionInfo: {
expression: "$feature.MARKER_ACTIVITY"
},
where: "MARKER_ACTIVITY IN ('Campground Camping', 'Sledding/Tubing')"
};
regardless of a space (or not) following the comma',' after Campground Camping.
Basically mimics this from the api:
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html
labelClass.where = "MARKER_ACTIVITY IN ('Picnicking', 'Group Camping')";
Yes, it does work using this expression
labelExpressionInfo: {
//expression: '"\u2714"'
expression: "$feature.MARKER_ACTIVITY"
},
where: "MARKER_ACTIVITY IN ('Campground Camping', 'Sledding/Tubing')"
However, it doesn't work when using '"\u2714"'
Correct, that part is on Jim here. I'm not sure where his layer is coming from....
Since I did get one simple use case working, I just created 2 LabelClasses and applied them. So in tandem they achieved what I was going for. I ran out of time trying to figure out the where clause. Here is my solution:
labelBase = {
symbol: {
type: 'text', // autocasts as new TextSymbol()
color: 'black',
font: { // autocast as new Font()
family: 'Material Icons',
size: size
}
},
labelPlacement: 'center-center',
labelExpressionInfo: {
expression: '"\u2714"'
}
};
labelClassDryRun = Object.assign({}, labelBase);
labelClassDryRun.where = "status = DRY_RUN";
labelClassServiced = Object.assign({}, labelBase);
labelClassServiced.where = "status = SERVICED";
......
labelingInfo: [labelClassServiced, labelClassDryRun, labelInfo]
Did you check whether this (removing the space after the comma) worked?
where: "status in ('PENDING','DRY_RUN')"