Label Definition / Expression

626
5
Jump to solution
12-19-2019 11:55 AM
jaykapalczynski
Frequent Contributor

Anyone know if and how I can create the Label expression that puts the values on 2 lines?

"expression":"$feature.Owner1 + ' GO TO NEXT LINE  ' + $feature.MapNumber "

LabelDefinition {
   json: {
      "labelExpressionInfo":{
         "expression":"$feature.Owner1 + '  ' + $feature.MapNumber "
      },
                
// SNIP

}  // END OF LAYER DEFINITION‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
ErwinSoekianto
Esri Regular Contributor

So the LabelDefinition takes JSON object based on this doc, LabelDefinition QML Type | ArcGIS for Developers, so I assume it would be something like "\\n"

See this, javascript - How do I handle newlines in JSON? - Stack Overflow 

View solution in original post

0 Kudos
5 Replies
jaykapalczynski
Frequent Contributor

Something like the vbNewLine used in ArcMap Label expressions?????

Tried this but no go

"expression":"$feature.Owner1 + '\n' + $feature.MapNumber"
0 Kudos
ErwinSoekianto
Esri Regular Contributor

So the LabelDefinition takes JSON object based on this doc, LabelDefinition QML Type | ArcGIS for Developers, so I assume it would be something like "\\n"

See this, javascript - How do I handle newlines in JSON? - Stack Overflow 

0 Kudos
jaykapalczynski
Frequent Contributor

Yea thats what I was referencing....looked everywhere...every place I looked and found something it was \n 

no where did i see if referenced with two \\  as your example \\n

But that seems to have worked...

// NO
"expression":"$feature.Owner1 + '\n' + $feature.MapNumber"


// YES
"expression":"$feature.Owner1 + '\\n' + $feature.MapNumber"
0 Kudos
ErwinSoekianto
Esri Regular Contributor

Glad that it works. You need to escape the "\" in the string (turning it into a double-"\")

jaykapalczynski
Frequent Contributor

I was almost there....ahahhahaahah

one stupid \

Have a great weekend

0 Kudos