[OSM-talk] Map legends: Another option

Ævar Arnfjörð Bjarmason avarab at gmail.com
Sat Jun 27 12:33:42 BST 2009

On Fri, Jun 26, 2009 at 11:17 PM, Lars Ahlzen<lars at ahlzen.com> wrote:
> Hi All,
> I know that there's been some talk about generating map legends/keys
> lately, and I don't know if there's a need for another option. It
> generated some interest when I mentioned it in my diary recently, however...
> I created a python script that generates an HTML legend (with images)
> based on a description of features to be included and one or more Mapnik
> XML configuration files. Thus, I can automatically generate legends for
> each zoom level of my map. If I modify the map style, I can just run the
> script again.
> Example at: http://toposm.com/ma/
> (click on "Show/Hide Legend" at the bottom right). It's dynamic, so it
> will reload when you zoom in and out.
> It was created for the TopOSM project, but it may be useful to other
> projects that use Mapnik for rendering.
> The script itself, and more info, is available at:
> http://wiki.openstreetmap.org/wiki/TopOSM#Map_legend

It would be neat if someone modified this to make it generate a legend
for the main web interface.

It's not that hard, here's an example of an entry for osmarender being added:


The "motorway" key is then used to look up a translation, e.g.:


Of course if you were going to modify it to have sections as in that
example you'd have to add section heading generation to the code, but
that shouldn't be that hard.

The main thing that needs to be done is to make something that can
read the main mapnik stylesheet and spit out something machine
readable that indicates what zoom level that feature is visible on, a
path to an associated PNG file, and optionally what section (e.g.
Roads) it's under.

Looks like this is mostly done at TopOSM, it's just a matter of
someone doing the needed integration legwork.

More information about the talk mailing list