Setting up the Annotation

Parent Previous Next

Setting up the Annotation


Some of the layers contain meaningful attributes (like road names) which can be displayed as labels along with the features. You may have to change several parameters of the layer in order to display the features with labels. When setting up the annotation the following steps should be made to achieve the desired result.


Inspect the feature attributes

In most cases the annotations contain one or more attributes of the features. In the first step you should make sure about the names of the feature attributes to be used to make up the labels when drawing the layer. You can use the MapManager feature selection options to inspect the feature attribute names and their values.


Choose the layer type

In some cases the features of the layers should be rendered along with the geometries or as text only layers without drawing the shape geometries. In the latter case you might want to change the type of the layer in the Data tab of the Layer Property Editor. If you want to render only an attribute of teh layer as labels without rendering the features of the layer the layer type of the text-only layer should be set to MS_LAYER_ANNOTATION

Select the label attribute (item)

To select the label attribute choose the desired Label Item in the Labeling tab of the Layer Property Editor. The combo box contains all of the possible values retrieved from the layers. In addition to the layer attributes the OGR layers contain a number of 'virtual attributes' related to the label feature styles which can also be used for the annotation. For more information about the OGR label style attributes see Using MapServer Label Property Binding.


Set up the label parameters

Select the Edit Default Label in the Labeling tab of the Layer Property Editor and then choose the desired type (MS_BITMAP or MS_TRUETYPE) and the label size in the Label Property Editor. For the truetype fonts the font type should also be selected from the supported fonts contained by the fontset attached to the map. You should also change the size, colour, offset and many other parameters supported by the Label Property Editor. Some of the attributes can be bound to the corresponding OGR feature attributes instead of specifying explicit values. For more information about these parameters see Label Attribute Binding.


Set up scale dependent rendering

You can specify whether the labels should be drawn at specific scales or the size of the labels should vary depending on the actual scale. For more information about this option see Scale Dependent Rendering.


Setting up fixed text labels

You might want to set up fixed labels not related to feature attributes (ie. copyright notice) by specifying the text member of the Class Property Editor. In this case all of the features belonging to this class will be labeled by using this text.


Setting up labels with multiple attributes

MapServer supports setting up labels based on multiple attributes by specifying an expression in the text member of the Class Property Editor. In this case the string may be given as an expression delimited using the ()’s. This allows you to concatenate multiple attributes into a single label. For example:


('[FIRSTNAME]' + ',' + '[LASTNAME]')


Using multiple labels within a class

Since MapServer 6.0 we can use multiple labels within a single class in the Layer Panel. With this option we can set up complex label rendering tasks like adding multiple labels for a single feature.


Using label styles

Since MapServer 6.0 we can use multiple styles within a single label in the Label Property Editor. When setting up the label styles we can use the geometry transformations labelpnt or labelpoly in Style Property Editor to define whether we use the centroid or the label bounding box as the shape when rendering the style. The label background color should also be defined by using labelpoly styles in MapManager