From OpenStreetMap Wiki
Jump to navigation Jump to search

Osmarender has many options to control the rendering of the map. Most of these options can be changed in the rules file and also on the command line when doing the XSL transformation. The Rules file is the one called osm-map-features-z17.xml or similar, depending on the zoom level you want to render.

<rules> attributes

The top level <rules> element has a number of settings that control the presentation of the rendered map:



The data attribute specifies the name of the XML file, downloaded from OpenStreetMap, that contains the map data. With some XSL processors this can be overridden on the command line.


The scale factor which means how many pixels are used for 1 longitude degree. 1 longitude degree length is shown as 10000 pixels * this scale factor. The default value is 1. Because SVG files are vector graphics, the attribute is used to adjust the width of the roads and size of the text relative to the size of the map, too. Changing this setting alters the size of the map canvas but does not alter the size of the items rendered on the map. A smaller value will make the roads wider and the text larger. A larger value will make the roads thinner and the text smaller. Values between 0.1 and 5 are typical depending on what you want to show.


All the symbols in the file will be scaled by this number. This is mainly used to scale symbol to have the same pixel size at all zoom levels.


Symbols from this directory will be included in generated svg file.

minimumMapWidth / minimumMapHeight

These settings override the normal bounding box settings to set the minimum size of the map canvas. The size is specified in kilometers, which is also the size of the grid boxes. If the map to be rendered is smaller than these settings it will be centered on the canvas.


OSM data can use several layers for the right drawing order for bridges, tunnels, etc. Normally this option is turned on (yes) which means that Osmarender will respect those layers when drawing the map. If you turn off this option (no), the layers will not be taken into account when drawing the map. This can make sense for special maps where the layers are not important (for instance a map of the railway network of a whole country where bridges can't be seen anyway). Not using layers speeds up the drawing process a little.


This attribute controls whether or not the title is drawn. The contents text will be drawn on the top.


This attribute controls whether or not the 0-1km scale is drawn. If showScale="yes" a scale will be draw at the bottom left corner of the canvas. The visual appearance of the scale is controlled by the CSS style classes map-scale-casing, map-scale-core, map-scale-bookend and map-scale-caption. These classes are part of the rules file.


This attribute controls whether or not a 1km grid is displayed across the map. By default the grid is drawn using faint blue lines. The visual appearance is controlled by the map-grid-line CSS class in the rules.


This attribute controls whether or not a border is displayed around the map boundary. The css classes map-border-casing and map-border-core control the visual appearance of the border.


This attribute controls whether or not the Creative Commons logo and license caption and the OpenStreetMap attribution is displayed in the bottom right of the map. If you switch this off please be sure to include license details for the map in some other way. It is a violation of the license terms to publish OpenStreetMap data without referencing the license. The license information is always included as a comment and in the RDF format in the SVG file, but this can only be seen when looking at the SVG source.


This attribute controls whether or not the controls for zooming and panning are included on the left-hand side of the map. If you are creating a map that will be converted to .png or printed then you probably don't need to show these controls. If you want to view the map interactively in an SVG viewer (eg Firefox, Adobe SVG3 plug-in for Internet Explorer or Batik-Squiggle) then these controls provide an easy way to zoom and pan the map. This is needed because some viewers, such as Firefox, do not provide any built-in user interface for zooming and panning. This will also include the JavaScript code needed for zooming and panning. Switch this off if you want to upload maps to Wikipedia, because it will allow SVG images to be uploaded, but will not allow them if they contain JavaScript.

CSS Classes

There are a number of css classes in the rules file which control the overall appearance of the map. The names of these classes all begin with map- and can be found at the end of the style section of the rules file. These can be customised to create a distinctive look and feel:

  <style type="text/css" xmlns="http://www.w3.org/2000/svg">
/* Title */
    .map-title {
      font-family: "DejaVu Sans",sans-serif;
      font-size: 20px;
      text-anchor: middle;
      fill: black;
    .map-title-background {fill: yellow;}

/* maparea */
    .map-background {
      fill: #a0ffa0;
      stroke: none;
/* map-decoration/grid */
    .map-grid-line {stroke: #800000;}
/* map-decoration/border */

    .map-marginalia-background {fill: #8080ff;}
    .map-scale-casing {stroke:#000000;stroke-width:5px;}
    .map-scale-core {stroke:#505050;stroke-width:5px;}
    .map-scale-caption {fill:#f0f0f0;}
    .map-scale-bookend {stroke:#000000;}
    .map-scale-caption {fill:#ffffff;}

The Results: Osmarander CSS Classes example.svg

Title area

This class controls the font size and color of the map title.
This class controls the background of the title area at the top of the map. Normally a white background is used.

Map area

This class controls the background colour of the map canvas.


This controls the appearance of the grid lines.


These two classes control the appearance of the map border. The casing is drawn first and then the core is drawn over using a 0.1km dash array.

Marginalia area

This class controls the background of the marginalia at the bottom of the map (ie. the scale and license) Normally a white background is used.


These two classes control the appearance of the map scale. The casing is drawn first and then the core is drawn over using a 0.1km dash array.
This class controls the appearance of the vertical tags at each end of the map scale.
This class controls the font size and color of the 0 and 1km captions on the map scale.


By default the boundary of the map is determined automatically by the contents of the .osm file. If you wish to render just some part of the .osm file you can use the bounds element to mask out data that you are not interested in. For example:

   maxlon="-0.3891926802448317" />

will select a small area of Lower Sunbury in Middlesex, UK. This element can be added to the rules file as a child of the <rules> element or it can be added to the .osm file as a child of the <osm> element. The following precedence order is used:

  • If the minimumMapWidth and minimumMapHeight settings are greater than the size of the bounding box then these minimums will be used. If you add a <bounds> element and it has no effect then this is probably why.
  • If the rules file contains a <bounds> element then that is used first.
  • If the rules file does not contain a <bounds> element but the .osm file does then that is used.
  • If neither the rules file or the .osm file contain a <bounds> element then the bounds are calculated automatically from the .osm map data.

It is hoped that the API and/or JOSM will implement the <bounds> element to indicate the boundary of the data requested, since some nodes will always be outside this.