1

I want to incorporate a simple text label into a mapfile-based map, such that the file's resulting images always display a specific text string (ideally in white over a black background) along the top of the image.

The image's pixel dimensions are known, but the map's extent will depend on outside factors; I'd rather not orient the label to spatial coordinates, but if I have to I will.

Despite how simple this seems to me, I can't seem to find any way to do it, including with legends (which don't seem to be super-imposed on the map anyway, but somehow work differently).

0

Create a point layer with a fixed feature and label and set it as a default layer. A sample mapfile follows. I wrote some comments for helping you to find the place to make edits for fine tuning.

LAYER
  NAME "copyright"
  METADATA
    "wms_title"     "copyright"
  END
  STATUS DEFAULT
  TYPE POINT
  TRANSFORM ll #set the image origin to be lower left
  FEATURE
    POINTS
      108 -8 #set the offset from lower left position in pixels
    END
    TEXT " © 2017 Our Company" #this is your displaying text
  END
  CLASS
    LABEL #defines the font, colors etc. of the text
      FONT "arial"
      TYPE TRUETYPE
      SIZE 15
      BUFFER 1
      COLOR 255 255 255 #white text
      STYLE #defines the box behing the label
         GEOMTRANSFORM LABELPOLY
         COLOR 0 0 0 #black box
         OUTLINECOLOR 255 0 0 #red border
      END #style
      FORCE TRUE
    END #label
  END #class
  UNITS PIXELS #sets the units for the feature object
END #layer

Because layer has status DEFAULT it will be rendered always and the result will look like this

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.