I would like to have a coloured box behind each road number on my map, matching the colour of the road it relates to and scaled to the length of the road number.

I understand this could be done with custom SVG symbols but it seems like it would be a time consuming process.

The road numbers in question are labels attached to points. Could I then work a solution where a box is created around that point as some of kind of data representation, basing the width on the string length of the road number?

EDIT: I think I may have found a way to do this with Ellipse Marker symbols. If I work it out I will post an answer.


Managed to work this out.

If you use the Ellipse Marker symbol type, you can choose the rectangle basic symbol and then set its width, height, and color options in Data Defined Settings. I did it like this:

  • Create new columns in the Attribute Table to contain box width, height and color.
  • To define the width of the box, use length(NAME)+x in the calculator (where NAME is the road number string and x is the amount of space around the text you want).
  • To define the height, simply enter a number in the height column (experiment)
  • To define the color, enter a color (hex/HTML) in the color column.
  • In the Symbols dialogue, set the type to Ellipse Marker and choose the rectangle shape
  • In the data defined settings tab, set the height, width and color options to correspond to your newly created columns et voila!

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.