I'm trying to label address points (with the ArcGIS Online labeling functionality) for one of our city's webmaps. Some of the addresses have unit numbers, some don't. I put together an Arcade expression that checks the "unit" field for values so that all points will be labeled correctly.
var unitVal = $feature.unit
var stVal = $feature.snumber
function mainfunc(unitVal,stVal){
if (unitVal == ' '){
return stVal
}
else {
return Concatenate([stVal,unitVal], ':')
}
}
mainfunc(unitVal,stVal);
The labels appear correctly in ArcGIS Online, but will not draw in a web application that calls on that AGO map. Has anyone come across the same issue?
Michael,
Have you tried adding semicolons at the end of your first two lines?
--- Rod
Hi Rod,
Just tried that, and no change, unfortunately.
Thanks for looking into it
I'm looking into this as well... will reply if I learn anything.
FYI, the expression could also be condensed to the following (but it doesn't really matter. Depends on your preference):
var unitVal = $feature.unit;
var stVal = $feature.snumber;
IIF(unitVal == ' ', stVal, Concatenate([stVal,unitVal], ':'));
Which version of the JS API are you using, 4.x or 3.x? Labeling isn't supported in 4.x yet. I was able to verify this in a 4.x app, but noticed the expected behavior in 3.x...
4.x test case: JS Bin - Collaborative JavaScript Debugging
3.x test case: JS Bin - Collaborative JavaScript Debugging