From OpenStreetMap Wiki
Jump to navigation Jump to search
[Edit] [Purge] Template-info.svg Template documentation

Taginfo2 is a newer alternative to embed Taginfo boxes in wiki pages. It offers several options to customize the output. Technically there is a fundamental difference in that it is programmed by using AJAX instead of using a MediaWiki extension.


This is just a shortcut for embeding Taginfo info boxes in other pages.

Syntax: {{taginfo2|key|value}}

Replace key with the name of the key tag and value with the desired value of the tag, or omit it to display the key's information.


There are also several options by setting parameters.

Syntax: {{taginfo2|key|value|option 1|option 2|...}}

link=yes – If set the template only displays the link to taginfo page without further data in the box.
rtype= – Is used to display information about relations of one type. Put in the desired type, e.g. route.
url= – To customize the taginfo url, e.g. instances of specific regions or countries (default = https://taginfo.openstreetmap.org).
Parameters for customizing the extent of displayed content (default = yes):
tagLink=yes/no – If set no, header of the box showing the tag's name is not displayed.
countAll=yes/no – If set no, the total amount is not displayed.
countNodes=yes/no – If set no, the amount of existence on nodes is not displayed.
countWays=yes/no – If set no, the amount of existence on ways is not displayed.
countRelations=yes/no – If set no, the amount of existence on relations is not displayed.
percentage=yes/no – If set no, the percentages behind the amounts are not displayed.
footer=yes/no – If set no, footer of the box linking to taginfo is not displayed.
width= – To manipulate the width of the box (default = 11em).











relation members and roles:

See also

How it works

This template is built from five files:

These files work as follows:

Step 1: Decide which type of box to show The purpose of the {{taginfo2}} template is simply to decide which of the two taginfo boxes to show. If it is a tag box (for a key or value), it calls {{taginfoAJAX}}. If it is a relation box, {{taginfoAJAX_relation}} is called.

Step 2: Build the html Next, the template builds up an HTML structure for the box. The template uses CSS classes to designate where the taginfo information should be loaded. The class scheme is as follows:

Tag box
CSS class Purpose
taginfo__key_value The overall container. Indicates that html within this box should be populated with taginfo data for the tag key=value.
all-count Populated with the total number of nodes, ways, and relations.
node-count Populated with the number of nodes.
way-count Populated with the number of ways.
rel-count Populated with the number of relations.
all-pct Populated with the percentage of objects in this key that have this value
node-pct Populated with the percentage of nodes in this key that have this value
way-pct Populated with the percentage of ways in this key that have this value
rel-pct Populated with the percentage of relations in this key that have this value
Relation box
CSS class Purpose
taginfo_relation__type The overall container. Indicates that html within this box should be populated with taginfo data for the relation type=value.
rel-count Populated with the number of usages of this relation.
member-count Populated with the aggregate number of members relations of this type.

Step 3: CSS styling In addition to providing styling, the associated CSS file ensures that the box is hidden until it is loaded.

Step 4: Javascript The javascript file runs one time on the page, scanning for taginfo boxes by CSS class selectors. For example, if the javascript routine discovers a <div> with the name taginfo__building_yes, that indicates that building=yes taginfo data should be loaded. The javascript makes an AJAX call to taginfo to retrieve the taginfo data, and then populates HTML matching the class selectors above with the retrieved taginfo data.

noscript support

If javascript support is not available, a simple link to taginfo's page for the relevant element will be shown.


The messages used by this template are translatable. You can provide translations by translating these messages:

Message Interface language or a fallback language
Taginfo-all All
Taginfo-nodes Nodes
Taginfo-ways Ways
Taginfo-relations Relations
Taginfo-all-count Objects with tag “$1=$2” in database
Taginfo-node-count Nodes with tag “$1=$2” in database
Taginfo-way-count Ways with tag “$1=$2” in database
Taginfo-relation-count Relations with tag “$1=$2” in database
Taginfo-all-fraction Fraction of all objects with key “$1”
Taginfo-node-fraction Fraction of all nodes with key “$1”
Taginfo-way-fraction Fraction of all ways with key “$1”
Taginfo-relation-fraction Fraction of all relations with key “$1”
Taginfo-header-relation $1 relation
Taginfo-members Members
Taginfo-member-count Members of “$1” relations in database
Taginfo-prevalent-roles Prevalent roles:
Taginfo-empty-role (empty role)
Taginfo-powered-by [$1 More details at $2]
Taginfo-no-such-tag This tag does not appear in the OSM database.
Taginfo-error Error loading from Taginfo API.

For example, to create a German translation for MediaWiki:Taginfo-all, an administrator must create MediaWiki:Taginfo-all/de.

This template is currently available in the following languages besides English: