curved label box

This label containing the road number 21 and the name Forrest Hill Road, was specified in the style sheet using a type of label format which allows you to insert boxes with background colors and borders. Boxes can be nested if you like. The road name is aligned with the road and curves round it, while the label sits in its own box above.

For this label I used the labelFormat attribute


inside the <label> element in the <layer>

The labelFormat attribute can be split up into a hierarchy of sections and commands. In this example there are two sections separated by a plus sign, which indicates concatenation:


for the road number (the 'ref' attribute)


for the main name.

The road number commands are:


to start the box; this command has the form {[ box style } and the box style is made up of CSS-like style commands with CartoType extensions such as color mixing. The border-radius command selects a radius for the curved box borders which is 50% of the height of the box;

ref to select the 'ref' attribute of the map object


{]} to end the box

The road name commands are:

"&#10;" to insert a newline; anything inside double quotes is inserted as is, and is an XML entity reference for the character 10, a newline

; to select the label attribute of the map object

{-} to set the baseline of the whole label to the baseline of this line

As you can see, the syntax is complicated but powerful. Of course we give CartoType users all the support they need to use this and other style sheet features.