1

I want to label the numbered roads at all scales with a symbol instead of text. Also, I would like to label the roads using an expression so I could use the symbol corresponding to the road number.

Right now, I can display a symbol in a label, but the text is still visible and all roads use the same symbol. I can't find a way to use expressions in a LABEL.

So how could I dynamically use a symbol as label, without text, according to a field attribute that stores the road number?

Here is how a part of my LAYER section looks like:

LABELITEM "NomRte"
CLASS
  NAME 'Autoroute'
  EXPRESSION (('[ClsRte]' eq 'Autoroute')and('[CaractRte]' ne 'Bretelle'))

  LABEL
    MINDISTANCE 750
    STYLE    # since to version 6
      symbol 'a10'
      MAXSIZE 24.0
    END # STYLE
  END # end of label

  STYLE
    WIDTH 2
    COLOR 0 0 0
    OUTLINECOLOR 0 0 0
    MAXSCALEDENOM 500000
  END #STYLE

1 Answer 1

1

I got that working. It is pretty simple, but I got confused in MapServer's documentation. My mapfile (layer level) now looks like this

LAYER

[...]

CLASS
  NAME 'Route régionale'
  EXPRESSION (('[ClsRte]' eq 'Régionale')and('[CaractRte]' ne 'Bretelle'))

  LABEL
    EXPRESSION ([NoRte] = 141)
    TEXT ' '
    MINDISTANCE 150
    STYLE    # since to version 6
      symbol 'r141'
      MAXSIZE 20.0
    END # STYLE
  END #LABEL


  LABEL
    EXPRESSION ([NoRte] = 243)
    TEXT ' '
    MINDISTANCE 300
    STYLE    # since to version 6
      symbol 'r243'
      MAXSIZE 20.0
    END # STYLE
  END #LABEL

  LABEL
    EXPRESSION ([NoRte] = 245)
    TEXT ' '
    MINDISTANCE 175
    STYLE    # since to version 6
      symbol 'r245'
      MAXSIZE 20.0
    END # STYLE
  END #LABEL
END #CLASS

[...]



END #LAYER

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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