Skip to content

Stylesheets

Maxim Rebguns edited this page Jul 26, 2025 · 8 revisions

This page describes the XML stylesheets used by FreePaperMaps.

Value formats

Hex color

A hexadecimal RGB color in the form of #?????? where ? is a hex digit.

Length

A number that optionally has a decimal point. Default units are on-the-map millimeters. The following on-the-map units are also supported:

  • mm: millimeters
  • in: inches
  • ft: feet
  • cm: centimeters
  • m: meters
  • px: pixels (1 px = (25.4 / 96) mm)
  • pt: points

Cap

One of:

  • butt
  • round
  • square

Join

One of:

  • miter
  • round
  • bevel

Count

A positive integer value.

Angle

A number that optionally has a decimal point. Default units are degrees (deg). Radians are supported (rad). Example: 3.14rad.

Attribution position

  • top-left
  • top-right
  • bottom-left
  • bottom-right

String

A sequence of any character.

Settings

Settings are written in key-value format:

<setting k="key" v="value"/>

Background color

<setting k="background-color" v="Hex color"/>

Attribution

<setting k="attribution-font" v="String (a font installed on your system)"/>
<setting k="attribution-font-size" v="Length"/>
<setting k="attribution-bg-color" v="Hex color"/>
<setting k="attribution-text-color" v="Hex color"/>
<setting k="attribution-position" v="Attribution position"/>
<setting k="attribution-text" v="String"/>

Selectors

Ways

<way id="Unique identifier">
  ... selectors (0 or more)
</way>

Nodes

<node id="Unique identifier">
  ... selectors (0 or more)
</node>

About selectors

A selector is used to determine whether a style applies to a piece of geometry. For example, we can create a selector that only matches paved paths:

<!-- The outermost way tag is treated as an "and". -->
<way id="paved-paths">
  <or>
    <key k="highway" v="footway"/>
    <key k="highway" v="path"/>
    <key k="highway" v="cycleway"/>
  </or>
  <or>
    <key k="surface" v="paved"/>
    <key k="surface" v="concrete"/>
    <key k="surface" v="asphalt"/>
  </or>
</way>

Specification:

  • Direct children of <selectors> should only be <node> and <way>
  • <node> and <way> can have zero ore more direct children, known as expressions
  • An expression is one of:
    • <tag> (cannot contain children) - has a key and value
      • Wildcard: the value of "" matches any value. For example: <tag k="building" v=""/> matches all building types
    • <and> (must contain one or more expressions) - logical AND
    • <or> (must contain one or more expressions) - logical OR
    • <not> (must contain one or more expressions) - logical NOT
  • In the case of <not> and the top-level <way> tag, if there is more than one expression as children of those tags, then it is implied that the expressions are within an <and>

Layers

Polyline

Draws a way as a line, going from point to point in order. Can be used for both closed and unclosed ways.

<polyline ... />

Options:

  • required ref
  • stroke (Hex color): line color
  • fill (Hex color): fill color (if not specified, then no fill is used)
  • thickness (Length): line thickness
  • cap (Cap): line end cap
  • join (Join): line join

NodeShape

Draws a polygon centered on a node.

<nodeshape ... />

Options:

  • required ref
  • required vertices (Count): the number of vertices of the polygon
  • required radius (Length): the distance from the node's coordinate position and each vertex
  • stroke (Hex color): line color
  • fill (Hex color): fill color (if not specified, then no fill is used)
  • thickness (Length): line thickness
  • cap (Cap): line end cap
  • join (Join): line join
  • angle (Angle): the angle in standard position from the x-axis of the first point in the polygon

Icon

Draws an SVG icon centered on a node.

<icon ... />

Options:

  • required ref
  • required path (String): path to an SVG icon file
  • fill (Color): if specified, attempts to override the SVG's default colors to this color - best suited for simple, single-color SVGs
  • width (Length): a maximum width for the icon
  • height (Length): a maximum height for the icon

Clone this wiki locally