I'm trying to write an expression in arcade for labeling properties.
What I want to do is only label certain roads,
The criteria is the road type is equal to either "Highway" "Major Arterial" or "Minor Arterial"
I'm new to expressions so any help is appreciated!
I usually use the Definition Query to set within the layer and the copy two more times and change it to like this
Definition Query road type is equal to Major Arterial
For example : One layer using "road type is equal to Highway"
copy and paste in the Contents and change again to like this road type is equal to Major Arterial
Then again copy and paste the same layer and change to road type is equal to Minor Arterial
Then for each layer, you can set labels for each certain roads ...
and I think that is the easiest way to do it.
However, you can do this with arcade if you want to. Something like this might work:
var highway = $feature.<attribute containing road type> = "Highway";
var majorArterial = $feature.<attribute containing road type> = "Major Arterial";
var minorArterial= $feature.<attribute containing road type> = "Minor Arterial";
var roadLabel = $feature.<Road Name Attribute>;
When(highway, roadLabel, majorArterial, roadLabel, minorArterial, roadLabel, "")
I don't know if that's the best way to do it but it should work.
Label pane > Class tab > SQL Query button
You don't need to properly write an expression, just select "Create a new expression" and it will give you the boxes to select which attributes you want labeled.