ArcGIS Pro Label Expression JavaScript

145
0
11-05-2019 10:55 AM
ChrisWiebke
New Contributor III
function FindLabel ( [RouteID],[Acres] )
{
  var dict = [{route:"002",label:"N-2",
  route:"004",label:"N-4",
  route:"013",label:"N-13",
  route:"020",label:"US-20",
  route:"073",label:"US-73",
  route:"075",label:"US-75",
  route:"083",label:"US-83",
  route:"084",label:"N-84",
  route:"136",label:"US-136",
  route:"159",label:"US-159",
  route:"183",label:"US-183"}];
  for (var route in dict)
  {
    var routeLabel = dict[route]["label"];
    route = dict[route]["route"];
    if (route == [RouteID])
      return routeLabel + "\n" + parseInt([Acres]) + " Acres"
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

The above code is only labeling the last highway value in the dictionary when used in the label class expression advanced editor.  Can anyone tell me why that is so, and how to label all the highways in dictionary?  I think I need to loop through a list of the [routeLabel]s, but when i try to add for routeLabel in route loop, it is not returning anything.  I guess i am not constructing the right objects? 

0 Kudos
0 Replies