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
I don't have an answer to your positioning question, but you can simplify your code
if ($feature.Facility_short == “Green River Plant” ||
$feature.Facility_short == “Red Creek Mine” ||
$feature.Facility_short == “Blue Mountain Refinery” ||
$feature.Facility_short == “Yellow Enterprises”) {
return $feature.Facility_short
}
Too bad Arcade doesn't seem to support "in"
I agree on the "in" front! And thank you for the shortened code! There's just not a lot documentation out there. Just curious, what does the " | |" stand for?
That's the "Logical or" operator. Here's a full list of the available operators: Logic | ArcGIS for Developers
Thank you again! So I assume you can use this || for as many OR statements as you want? The documentation says one of two, but obviously this code example above shows we can do more than 2.
This stuff is nice. What I'm wondering is where you are using this code, in the symbology, labels? I would like to use this in AGOL maps, but am not clear how to go about actually doing it.
Sorry to hijack the post with another question.
No problem at all! I'm using this code in the Labels. When you Manage Labels, you choose "Custom (Expression)" from the drop-down menu for Text.
Here's another good resource I was forwarded to:
https://developers.arcgis.com/arcade/guide/logic/#if-statements
Let me know if you have any other questions and I'll try to tell you what I've learned.
Thank you Jason!
Jason,
How do you use TextFormatting.Newline? Attempting to use this in Labels and it is not honoring the newline.
Using:
$feature.Sta_Num + TextFormatting.NewLine + $feature.Sta_Name
Newline doesn't work right now. Take a look at this discussion: https://community.esri.com/message/658173-re-arcade-text-constant-for-textformattingnewline-is-addin...