-
Notifications
You must be signed in to change notification settings - Fork 1
ShieldSymbolizer
ShieldSymbolizer supports all options of TextSymbolizer and the following additional options:
parameter | value | default |
---|---|---|
base | Base symbol template (See below) | |
file | The file to use for the shield background | |
opacity | opacity of the image used for the shield | 1 |
text-opacity | opacity of the text placed on top of the shield | 1 |
unlock-image | No known function | "false" |
shield-dx | offset the shield image and text horizontally | 0 |
shield-dy | offset the shield image and text vertically | 0 |
transform | Transform image |
dx, dy (from TextSymbolizer) only move the text, but not the Shield. This behavior will be changed in a future release of mapnik. (See below).
placement="line"
only means placement along a line for ShieldSymbolizer, whereas for TextSymbolizer it rotates the text too. Add the spacing
parameter to get the ShieldSymbolizer to repeat along the line, otherwise placement="line"
and placement="point"
will look the same.
Add
<FileSource name="foo">/home/bar/baz/</FileSource>
to the beginning of your stylesheet and then use
<ShieldSymboliser base="foo" name="bridge">
to refer to /home/bar/baz/bridge.
ShieldSymbolizer can be used to label points.
E.G. If you want to place points on cities and their name above it. If you try to use a TextSymbolizer and a PointSymbolizer separated you will often see points without texts and/or texts without points.
To draw labeled points configure your shield symbolizer with placement = point and custom value for dx/dy to move the text around the point
Setting up a sample shield symbolizer, from the Cascade Users of OpenSource GeoSpatial (CUGOS) list: http://groups.google.com/group/cugos/browse_thread/thread/b62b4890e1933bba
<Style name="My Style">
<Rule>
<ShieldSymbolizer face-name="DejaVu Sans Bold" size="6" fill="#000000" file="images/shield.svg" width="20" height="20" spacing="100" transform="scale(2.0,2.0)" min-distance="50">[NAME]</ShieldSymbolizer>
</Rule>
</Style>
shield = ShieldSymbolizer(Expression('[NAME]'),'DejaVu Sans Bold',6,Color('#000000'),PathExpression('images/ushighway_shield_20.png'))
shield.min_distance = 50
shield.label_spacing = 100
shield.displacement = (dx,dy)
rule_type rule;
/* Parameters:
name
face name
size
color
image
image type
width
height
*/
shield_symbolizer ss("[NAME]", "DejaVu Sans Bold", 6, color(0, 0, 0), "/path/to/icon.png", "png", 20, 20);
ss.set_label_placement(mapnik::LINE_PLACEMENT); // Place label along the line
ss.set_displacement(dx, dy);
ss.set_label_spacing(min_distance);
rule.append(ss);
http://www.routemarkers.com/
http://www.weait.com/content/badges-badges
parameter | value | default |
---|---|---|
shield-dx, shield-dy | Move shield only. | 0 |
dx, dy | With unlock_image = true: move text only. | 0 |
With unlock_image = false: move text and shield | 0 | |
unlock_image | True: Shield base point is always the input line/point (usecase: labeling bus stations). | 0 |
False: Shield base point is the center of the text (i.e. depends on dx,dy,vertical-alignment, horizontal-alignment) (usecase: highway shields) |