Skip to content
thangalin edited this page Jul 18, 2012 · 7 revisions

Cascadenik implements cascading stylesheets for Mapnik.

It's an abstraction layer and preprocessor that converts special, CSS-like syntax into Mapnik-compatible style definitions. It's easier to write complex style rules using the alternative syntax, because it allows for separation of symbolizers and provides a mechanism for inheritance.

Cascadenik supports many of Mapnik’s features in a simple declarative form:

/* Define a few colors */
@color_road_name: #000;
@color_background: #fff;
@color_road_line: #f90;

/* Start with a plain background. */
Map
{
    map-bgcolor: @color_background;
}

/* Draw the roads. */
#roads
{
    /* Usually, 3px wide */
    line-width: 3;
    line-color: @color_road_line;
    
    /* Make the important ones wider */
    &[kind=major] { line-width: 4 }
    &[kind=highway] { line-width: 5 }
    
    /* Add the road names. */
    name
    {
        text-placement: line;
        text-face-name: "DejaVu Sans Book";
        text-fill: @color_road_name;
        text-size: 12;
    }
}

See more examples at https://github.com/mapnik/Cascadenik/wiki/Examples.

Links

Clone this wiki locally