Home | Docs | Issue Tracker | FAQ | Download | |
We can also add labels to our map...
MapServer has a very flexible labeling engine. It supports native bitmap as well as truetype fonts. Font scaling is supported with truetype. The labeling angles and placements can be customized... If you take the time to learn the many parameters involved in creating good labels, you will be rewarded with informative and aesthetically pleasing maps.
This is what the map file looks like: Example1-4.map.
The map file structure, by objects, looks like this:
MAP
(states_poly) LAYER----------|---------LAYER (states_line)
(land) CLASS-----|-CLASS (water) |-CLASS
STYLE-|-LABEL |-STYLE |-STYLE</pre>
Here we introduce a few more parameters along with the LABEL object:
This specifies the shadow color of the label text.
Note
Since MapServer 6, LABEL STYLE with GEOMTRANSFORM LABELPOLY must be used instead. The tutorial files have not been updated.
Specifies the shadow size. The value corresponds to the X and the Y shifts in pixels. So, “2 2” means two pixels wide by two pixels high.
Note
Since MapServer 6, LABEL STYLE with GEOMTRANSFORM LABELPOLY must be used instead. The tutorial files have not been updated.
BUFFER
The padding (in pixels) for each label. This is used to enhance readability. A BUFFER of 4 pixels mean that no label will be drawn within four pixels of each other. Again, change to see how it works.
You can also create labels separate from a POLYGON layer. You do this with the ANNOTATION data type. Have a look at the next example’s map file to see how you’d implement this kind of labeling. You will notice that the CLASS object within the “label” layer has a COLOR parameter value of “-1 -1 -1”. The negative number tells MapServer to give this CLASS a transparent color (the label IDs don’t show up). Once again, play with the values to understand how it affects the map.