Select to view content in your preferred language

ArcGIS Online Labels with Arcade Custom Expression Won't Render in App

2746
4
01-19-2017 12:29 PM
MichaelSakinejad2
Emerging Contributor

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?

Labels in ArcGIS Online Lack of Labels in Webmap

0 Kudos
4 Replies
by Anonymous User
Not applicable

Michael,

     Have you tried adding semicolons at the end of your first two lines?

--- Rod

0 Kudos
MichaelSakinejad2
Emerging Contributor

Hi Rod,

Just tried that, and no change, unfortunately.

Thanks for looking into it

0 Kudos
KristianEkenes
Esri Regular Contributor

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], ':'));
0 Kudos
KristianEkenes
Esri Regular Contributor

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 

0 Kudos