Is there any syntax in the new Arcade language that can but used with labels in AGO that will tell certain features to label to the left, certain features to label to the right, etc? The problem I'm having is I have several facilities that are congregated in a particular area pretty tightly, and it would help to place some of the labels in different positions around their corresponding feature.
Up until now the only way I've been able to get around this is to create duplicate layers, and label each one "Facilities - Left Labels", "Facilities - Right Labels", etc. But I'd rather not do this if I could write the code a certain way within just one feature layer. Here's the code I've got so far that only shows certain labels for features in a layer (thanks to Kelly Gerrow @ ESRI):
if ($feature.Facility_short == “Green River Plant”) {return “Green River Plant”}
else if ($feature.Facility_short == “Red Creek Mine”) {return “Red Creek Mine” }
else if ($feature.Facility_short == “Blue Mountain Refinery”) {return “Blue Mountain Refinery” }
else if ($feature.Facility_short == “Yellow Enterprises”{return “Yellow Enterprises” }
Thank you all for any help you can provide!
Jason
Thanks for the headsup kenbuja
I know this post doesn't exactly cover my question but it does have to do with labeling. I have a point feature class for tax map annotation, with a text string and an angle field. I am trying to get that to label properly using the arcade custom expression. I can't seem to find anything telling me how to do this, although I do see several references which state that this can be used for label rotation display. Help, please!
Sorry. Syntax error. Here's the corrected version of an alternate approach somewhat similar to IN:
var items = [ “Green River Plant”, “Red Creek Mine”, “Blue Mountain Refinery”, “Yellow Enterprises” ];
IIF ( IndexOf(items, $feature.Facility_short) > -1, $feature.Facility_short, null);
Thank you Kristian! One more request. Do you know the code to tell certain labels to show up to the left of a point, certain labels to the right, etc? I noticed on one of the documentation pages there was something called “labelplacement”, but I’m not sure if this is code that can be used in ArcGIS Online or not. If you know, then that would solve my last problem! Otherwise, I was just going to duplicate the Master Facility layer, and create duplicative layers called “Master Facility – Left Labels”, “Master Facility – Right labels” etc. And then hide those duplicative layers in the Web App Builder and from the Legend.
Thank you again for your help!!!
I don't believe you can configure label placement using Arcade syntax (yet). I just use label classes to handle placement as this sample demonstrates: Label features using Arcade expressions | ArcGIS API for JavaScript 3.20
Note that ArcGIS Online only supports adding one label class per layer. I'm not sure if support for adding more will be added in the future, but in the mean time I would configure this in the custom app or template. Otherwise you can also use the approach you described. Hope that helps!
Kristian, thanks so much again! Yes I figured it was probably an issue with the version of JavaScript ArcGIS Online uses. Hopefully they will add support for labelplacement syntax in a future update. For now, I'll just to have to stick with my multi-layer solution.
Yes, you should be able to put as many in as you like. For example, this code
if ($feature.Habitat == "HARD" ||
$feature.Habitat == "AGRF" ||
$feature.Habitat == "SCR") {
return $feature.Habitat
}
yields this map
FANTASTIC !!!! You have been such a valuable resource! 🙂