shield

Contents

Draws a shield on the map. A shield is effectively a combination of a shape and a text symbols. The shield can resize its shape according to the size of the text.

Introduction

Shields are symbols useful for representing a combination of textual and graphical information. The common use for shields is to draw road numbers.

Here's an example rule for the OSM map-style shield for motorways:

target : motorway
	define
		font-family : Tahoma
		text-align-horizontal : center
		text-align-vertical : center
		text : ref
		font-size : 12
		text-color : #fcfcfb
		text-halo-width : 0
		shape : custom
		shape-def : p:#809bc0;pw:5;f:#809bc0;m:-10,-10;l:10,-10;a:10,10,10,10;l:-10,10;a:10,10,-10,-10;z;p:#fcfcfb;pw:2;m:-10,-10;l:10,-10;a:10,10,10,10;l:-10,10;a:10,10,-10,-10;z
		shield-padding-left : 5
		shield-padding-right : 5
		shield-padding-top : 7
		shield-padding-bottom : 7
		shield-resize-mode : free
	draw : shield

Limitations

Currently shields are resized proportionally. This means that if you use an oval (arc) in your custom shield (like in the above example) and use the free style for shield-resize-mode, the arc can be distorted from a circular shape into an ellipse shape (depending on the final size of the shield).

I plan to fix this limitation in the future. In the meantime, a workaround is perhaps to use the fixed shield-resize-mode, in the case of our motorway shield:

target : motorway
	define
		font-family : Tahoma
		text-align-horizontal : center
		text-align-vertical : center
		text : ref
		font-size : 12
		text-color : #fcfcfb
		text-halo-width : 0
		shape : custom
		shape-def : p:#809bc0;pw:5;f:#809bc0;m:-10,-10;l:10,-10;a:10,10,10,10;l:-10,10;a:10,10,-10,-10;z;p:#fcfcfb;pw:2;m:-10,-10;l:10,-10;a:10,10,10,10;l:-10,10;a:10,10,-10,-10;z
		shield-resize-mode : fixed
		shape-size : 30
	draw : shield

Properties

Important properties:

Other properties: