Taginfo/Taglists
The taginfo API can give you extended lists of tags. You decide which tags you want in that list and taginfo will add element types, description, example images, and (optionally) usage counts from the database.
This can be used to create tables of tags in the OSM wiki using a simple template. Instead of assembling and maintaining the tables manually, let taginfo do the work for you.
Currently we are rolling out Taglists in this wiki. For the project page, see Taginfo/Taglists/Wiki project. For advantages/disadvantages between taglists and templates, see taglists_vs_templates.
Embed tag lists in this wiki
Use the template {{Taglist}} with a list of tags as the tags
parameter:
{{Taglist|tags=highway=motorway,trunk,primary,secondary,tertiary,maxspeed=*,oneway=yes}}
And you'll get a table like this:
Note that you can use the Asterisk (*) instead of a value to get the description/icon from a key.
Setting the language
You can set the language the list should be in using the lang
parameter. The default is en (English). So...
{{Taglist|tags=highway=motorway,trunk,primary,secondary,tertiary,oneway=yes|lang=ru}}
...gives you a table in Russian:
Note that for the localization to work two things are needed:
1. Taginfo needs to have the texts used in the table header for the language, they need to be in https://github.com/joto/taginfo/blob/master/web/public/js/taglists.js. (Updates will only be available after manual intervention which can take a few days.)
2. The key/tag description must be available in the wiki in this language. Update the info box on the key/tag page for this to work (description will not used from data items). Updates will be available after the next update of taginfo, usually within a day.
Add object counts to table
Add the parameter with_count=true
if you want to add the usage counts from the database:
{{Taglist|tags=highway=motorway,trunk,primary,secondary,tertiary,maxspeed=*|with_count=true}}
will show up as:
Add rendering example to table
Add the parameter with_rendering=true
if you want to add an image showing how the tag is rendered in openstreetmap-carto, the standard OSM map stylesheet:
{{Taglist|tags=shop=tea,bag|with_rendering=true}}
will show up as:
.
VERY IMPORTANT : the renderings of taglists don't work if there is one (or more) underscore in the file's name. But it will work if you replace all the underscores by a space. Example : for the tag tree_row, the name of the rendering file is File:Rendering-natural_tree_row-mapnik.png. In the osmcarto-rendering of the english page for the tag natural:tree_row, in the ValueDescription, you have to write : osmcarto-rendering=File:Rendering-natural tree row-mapnik.png.
If you have changed the name of the file in the ValueDescription of the tag, keep in mind that you will have to wait one day to see the result : taglists work with the taginfo API. Taginfo is updated once a day so you have to wait the next update to see the result in your taglists.
Create a list with "all" tags for a key
You can create a list of "all" tags for a given key by just giving that key in the list:
{{Taglist|tags=access}}
The list will not contain all tags, but only those documented on the wiki. To be more specific: The tag page must exist and contain the Template:ValueDescription info box. This use is probably not what you want in most cases, because the list can and will change without you noticing and you might get strange tags in there you didn't want to have. So it is better to write down exactly what tags you want to have in this list.
Embed tag lists in your own web pages
Include jQuery and taglists.js
in your web page:
<script type="text/javascript" src=".../jquery-1.9.0.min.js"></script> <script type="text/javascript" src="https://taginfo.openstreetmap.org/js/taglists.js"></script>
Now you can add tag lists to your web page by adding a small HTML snippet:
<div class="taglist" data-taginfo-taglist-tags="highway=motorway,trunk,primary,secondary,tertiary"> </div>
The list of tags can be anything in the format: KEY1=VALUE1a,VALUE1b,...,KEY2=VALUE2a,VALUE2b,.... If you only add a key, the table will contain all values of that key we have a wiki page for.
You can add options using data-taginfo-taglist-options
. This allows you to change the language used:
<div class="taglist" data-taginfo-taglist-tags="natural=wood,landuse=forest" data-taginfo-taglist-options='{"lang": "de"}'> </div>
And you can add usage counts from the database:
<div class="taglist" data-taginfo-taglist-tags="natural=wood,landuse=forest" data-taginfo-taglist-options='{"with_count": true}'> </div>
Lastly you have to call the convert_to_taglist
function to create the tables:
<script type="text/javascript"> jQuery(document).ready(function() { taginfo_taglist.convert_to_taglist('.taglist'); }); </script>
This will replace the div
you entered into your page with the table.
The table
element will have a class of taginfo-taglist
. You can use this to style the table with CSS.
This functionality is using the tags/list
taginfo API call. See https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_tags_list for further information.