Template:Taginfo2/doc

From OpenStreetMap Wiki
Jump to navigation Jump to search

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.

Usage

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.

Options

There are also several options by setting parameters.

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

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).

Parameters

taginfo box (version 2)

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
tag key1

name of the key tag

Example
highway
Stringsuggested
tag value2

value of the tag, or omit it to display the key's information

Example
residential
Stringsuggested
rtypertype

type of relation, to display information about relations of one type

Example
route
Stringoptional
urlurl

to customize the taginfo url, e.g. instances of specific regions or countries

Default
https://taginfo.openstreetmap.org
Example
https://taginfo.geofabrik.de/north-america/us/new-york
Stringoptional
tagLinktagLink

If set no, header of the box showing the tag's name is not displayed.

Example
no
Stringoptional
countAllcountAll

If set no, the total amount is not displayed.

Example
no
Stringoptional
countNodescountNodes

If set no, the amount of existence on nodes is not displayed.

Example
no
Stringoptional
countWayscountWays

If set no, the amount of existence on ways is not displayed.

Example
no
Stringoptional
countRelationscountRelations

If set no, the amount of existence on relations is not displayed.

Example
no
Stringoptional
percentagepercentage

If set no, the percentages behind the amounts are not displayed.

Example
no
Stringoptional
footerfooter

If set no, footer of the box linking to taginfo is not displayed.

Example
no
Stringoptional
widthwidth

to manipulate the width of the box

Default
11em
Example
7em
Stringoptional

Examples

{{taginfo2|highway|residential}}

{{taginfo2|highway|}}

{{taginfo2|highway|residential|tagLink=no}}

{{taginfo2|highway|residential|footer=no}}

{{taginfo2|highway|residential|countNodes=no|countWays=no|countRelations=no}}

{{taginfo2|highway|footer=no}}

{{taginfo2|highway|residential|footer=no|tagLink=no|countNodes=no|countWays=no|countRelations=no}}

{{taginfo2|highway|residential|percentage=no|footer=no|tagLink=no|countAll=no|width=7em}}

{{taginfo2|highway|residential|url=https://taginfo.openstreetmap.org.uk}}

{{taginfo2|tiger:reviewed|no|url=https://taginfo.geofabrik.de/north-america/us/new-york}}

relation members and roles:
{{taginfo2|rtype=route}}

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.

Translations

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 French translation for MediaWiki:Taginfo-all, an administrator must create MediaWiki:Taginfo-all/fr.

To add translation, copy messages below, change "yyy" to a proper language code, translate and write your request on Wiki:Requests for administrator attention.

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

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

Languages

See also