Taginfo/Taglists

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Taginfo/Taglists
· Afrikaans · Alemannisch · aragonés · asturianu · azərbaycanca · Bahasa Indonesia · Bahasa Melayu · Bân-lâm-gú · Basa Jawa · Baso Minangkabau · bosanski · brezhoneg · català · čeština · dansk · Deutsch · eesti · English · español · Esperanto · estremeñu · euskara · français · Frysk · Gaeilge · Gàidhlig · galego · Hausa · hrvatski · Igbo · interlingua · Interlingue · isiXhosa · isiZulu · íslenska · italiano · Kiswahili · Kreyòl ayisyen · kréyòl gwadloupéyen · Kurdî · latviešu · Lëtzebuergesch · lietuvių · magyar · Malagasy · Malti · Nederlands · Nedersaksies · norsk bokmål · norsk nynorsk · occitan · Oromoo · oʻzbekcha/ўзбекча · Plattdüütsch · polski · português · português do Brasil · română · shqip · slovenčina · slovenščina · Soomaaliga · suomi · svenska · Tiếng Việt · Türkçe · Vahcuengh · vèneto · Wolof · Yorùbá · Zazaki · српски / srpski · беларуская · български · қазақша · македонски · монгол · русский · тоҷикӣ · українська · Ελληνικά · Հայերեն · ქართული · नेपाली · मराठी · हिन्दी · অসমীয়া · বাংলা · ਪੰਜਾਬੀ · ગુજરાતી · ଓଡ଼ିଆ · தமிழ் · తెలుగు · ಕನ್ನಡ · മലയാളം · සිංහල · ไทย · မြန်မာဘာသာ · ລາວ · ភាសាខ្មែរ · ⵜⴰⵎⴰⵣⵉⵖⵜ · አማርኛ · 한국어 · 日本語 · 中文(简体)‎ · 吴语 · 粵語 · 中文(繁體)‎ · ייִדיש · עברית · اردو · العربية · پښتو · سنڌي · فارسی · ދިވެހިބަސް

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.

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,oneway=yes}}

And you'll get a table like this:

LOADING TAG LIST... (If you do not see this tag list, you need to enable Javascript)

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:

LOADING TAG LIST... (If you do not see this tag list, you need to enable Javascript)

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. Updates will be available after the next update of taginfo, usually within a day.

If not specified, the setting is also determined from the web address.

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,oneway=yes|with_count=true}}

will show up as:

LOADING TAG LIST... (If you do not see this tag list, you need to enable Javascript)

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 the standard OSM style:

{{Taglist|tags=shop=tea,bag|with_rendering=true}}

will show up as:

LOADING TAG LIST... (If you do not see this tag list, you need to enable Javascript)

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}}
LOADING TAG LIST... (If you do not see this tag list, you need to enable Javascript)

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.