Template:Taginfo2

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

Usage

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

There is also a name parameter:

  • "link": if set to "yes" the template only displays the link to tag info page.


{{taginfo2|key|value}}

Examples

{{taginfo2|highway|residential}}

{{taginfo2|highway|}}

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

{{taginfo2|highway|residential|footer=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|url=https://taginfo.openstreetmap.org.uk}}

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.