Exercise 2: Add labels that use an expression
 
 
 

You can label each parcel with text that is determined by an expression. In this exercise, you create a label for each parcel that displays the parcel address on two lines.

The Style Editor should still be open from the previous exercise.

NoteThis exercise uses the map you modified in Exercise 1: Create a theme.

To add labels using expressions

  1. In the Style Editor, click the entry under Feature Label for the first rule in the theme.

    Because you are theming the Parcels feature, you have one entry for each theme rule.

  2. In the Style Label dialog box, click Property To Display, scroll down to the bottom of the list, and click Expression.

    You can use an expression to determine the text for labels.

  3. To create the two-line label, enter Concat (ADDRESS, Concat ('\n', STNAME))

    The Concat operator combines multiple properties and uses the '\n' argument to insert a line break.

  4. Validate the expression.
  5. Click OK in the Create/Modify Expressions window and again in the Style Label dialog box.
  6. In the Style Editor, click the entry under Feature Label for the second rule in the theme.
  7. In the Style Label dialog box, click Property To Display, scroll down to the bottom of the list, and click the Concat expression you created earlier. Click OK twice.

    Once you create an expression for a label, you can select it from the Property To Display list. You do not have to re-create it each time.

  8. Repeat steps 5 and 6 for each entry in the theme for which you want labels.
  9. Close the Style Editor to see the changes.

Where you are now

You themed the Parcels layer, using a calculated property as the basis for the theme. You added labels whose content was determined by an expression.

To continue this tutorial, go to Lesson 5: Publish Your Styled Map to MapGuide.