As I indicated in my last post, RT MapServer Exporter is lack of Label feature exporting capability (or I haven’t found the correct way to export MapFile with Label or my QGIS and RT MapServer Exporter have compatibility issue, etc). In this post, I’ll talk about how to manually add simple label to a vector layer in MapFile.
The following example is a polygon layer with simple LABEL turned on. As you can see, line 21, 31-37 are highlighted, these lines indicate the relevant label settings.
- Line 21. ‘LABELITEM’ is the field name in attributes to use for labelling.
- Line 21-37 defines label color, font, font size and position.
LAYER DATA "buildings.dbf" EXTENT 472881.8743 6969098.5894 520448.0429 7029925.04 METADATA "ows_title" "buildings" END # METADATA NAME "buildings" PROJECTION "proj=utm" "zone=56" "south" "ellps=GRS80" "towgs84=0,0,0,0,0,0,0" "units=m" "no_defs" END # PROJECTION STATUS ON TILEITEM "location" TYPE POLYGON UNITS METERS LABELITEM "UNITID" CLASS NAME "Single symbol" STYLE COLOR 204 245 161 END # STYLE STYLE OUTLINECOLOR 0 0 0 WIDTH 0.26 END # STYLE LABEL COLOR 255 0 0 TYPE TRUETYPE FONT "arial-italic" SIZE 12 POSITION AUTO END #LABEL END # CLASS END # LAYER
They are all pretty clear except the ‘FONT’ object. The FONT object indicates the font alias to use for labelling. The font aliases are stored in a text file which must be set in ‘FONTSET’ object. The fontset text file contains two columns, font alias and truetype font file path. See the following chart, hope it helps.
For more information, please refere to the official MapFile documentation.