Template:Mapbox/doc
Template:Documentation subpage Template:Uses Wikidata Template:Sister project This template adds a box to the right of the page, which includes a link to an interactive full-screen OpenStreetMap map that displays additional data – either from:
- data stored in GeoJSON format on Commons;
- line/polygon features in OpenStreetMap;
- coordinates, either supplied or from Wikidata;
- raw GeoJSON, preferably transcluded from another page.
Note:
- GeoJSON files cannot currently be directly uploaded. Instead, on Commons, create a page that is in the
Data:
namespace and ends in.map
– see mw:Help:Map Data for further information. - To make OpenStreetMap (OSM) features available, add the Wikidata key to the OSM relation (and wait 1 or 2 days) – see mw:Help:Extension:Kartographer#External_data and mw:Help:Extension:Kartographer/OSM for further information.
Usage
{{Mapbox}} utilises Template:Maplink. As a result, usage of the two templates is very similar.
Type | Code | Notes | Example |
---|---|---|---|
Data page on Commons | {{mapbox|from=}} |
specify .map data page in from= , excluding the Data prefix |
Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Raw GeoJSON data | {{mapbox|raw=}} |
e.g. {{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}} | Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Line of a border or a linear feature from OSM | {{mapbox|type=line|id=}} |
id= only required if the Wikidata item isn't linked to the current page |
Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Shape from OSM | {{mapbox|type=shape|id=}} |
id= only required if the Wikidata item isn't linked to the current page |
Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Inverted shape from OSM | {{mapbox|type=shape-inverse|id=}} |
id= only required if the Wikidata item isn't linked to the current page |
Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Point feature from Wikidata coordinates | {{mapbox|type=point|id=}} |
id= only required if the Wikidata item isn't linked to the current page |
Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Point feature from specified coordinates | {{mapbox|type=point|coord=}} |
Use Template:Tl template to specify coordinates | Errore Lua in package.lua alla linea 80: module 'Module:Yesno' not found. |
Full parameter set – data page
{{mapbox |from= |zoom= |text= |text-left= |above= |below= }}
Full parameter set – raw data
{{mapbox |raw= <!-- preferably {{Wikipedia:Map data/subpage}} --> |zoom= |text= |text-left= |above= |below= }}
Full parameter set – OSM features
{{mapbox |type= |id= |title= |description= |stroke-color= |stroke-width= |zoom= |text= |text-left= |above= |below= }}
Full parameter set – point features/coordinates
{{mapbox |type=point |id= |title= |description= |coord= |marker= |zoom= |text= |text-left= |above= |below= }}
Multiple links
Up to five links can be included within the one box by adding "2", "3", "4" or "5" to the end of the parameter name - e.g.data2
or description2
. All parameters support this except for above
, below
and text-left
. Unlike the first link (where it is optional), the text
parameter is required for links 2-5.
Parameters
Parameters affecting the maps
- type
- Type of data. Valid values are:
line
– a geoline feature from OSM (e.g. a road)shape
– a geoshape feature from OSM (e.g. a state or province)shape-inverse
– a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath)data
– a geoJSON data page on Commons (parameter is optional in this case)point
– a point feature (coordinates)
- id
- (or ids)
- Wikidata id (Q-number) that the OSM feature is tagged with. Separate multiple ids with a comma. Defaults to the current page's Wikidata id (if Template:Para not set).
- from
- The JSON (.map) file from Commons to display (excluding the
Data:
prefix) - raw
- raw GeoJSON (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See below for more information.
- title
- Title of the feature (for features from OSM), displayed when the feature is clicked on; default is the page title
- description
- Description of the feature (for features from OSM), displayed when the feature is clicked on; optional
- coord
- Coordinates to display for a point feature. Use Template:Tl template to specify coordinates. If not set, coordinates will be retrieved from Wikidata.
- marker
- Name of Maki marker image to display at the point feature. See mw:Maps/Icons for options. Defaults to
marker
(plain marker) if not set. - stroke-color
- (or stroke-colour)
- Colour code for the colour used to draw the feature (for features from OSM); default is
#555555
(Template:Color box) - stroke-width
- Width for the lines used to draw the feature (for features from OSM); default is
5
- zoom
- Zoom level, from
1
to19
(larger numbers zoom in further); will be automatically determined if not set
Parameters affecting the box
- above
- Content (such as explanatory text) appearing above the links
- below
- Content (such as explanatory text) appearing below the links
- text
- Text to display for the link; default is "View map"
- text-left
- Set this to
yes
to change the link text from centre-aligned to left-aligned
When to use the raw parameter
The "raw" parameter allows the same inputs as the full <maplink> function. It allows you to:
- Use GeoJSON data directly
- Use a combination of data sources together (direct GeoJSON, external data from Wikimedia Commons and external data from OpenStreetMap)
- Have more options for directly styling data (data from Commons will inherit the styling specified in the .map page)
- Include multiple pieces of external data from Wikimedia Commons
- Use Wikidata queries to obtain information for the map
- Use templates - if a map includes direct GeoJSON or many components, placing the data in a template will avoid cluttering the article text
Gotchas
- When retrieving lines or shapes from OSM, you can't style the fill colour or the opacity level of fills or strokes (unless you use the Template:Para parameter).
- The following code utilising the Template:Para parameter won't work because the curly brace to close the GeoJSON is adjacent to the curly braces to close the template:
{{Mapbox|raw= {"type": "ExternalData","service": "geoshape","ids": "Q13518258"}}}
- To fix it, put a space before the two template braces or move them to a separate line.
- Template:Tl's multiple features functionality doesn't work; use Template:Para instead.
See also
- Wikipedia:Maps for Wikipedia, a list of mapping tools available on Wikipedia
- Template:Attached KML
<templatedata>
{
"params": {
"above": {
"label": "Above",
"description": " Content (such as explanatory text) appearing above the links",
"type": "string"
},
"below": {
"label": "Below",
"description": "Content (such as explanatory text) appearing below the links",
"type": "string"
},
"text-left": {
"label": "Left-align text",
"description": "Set this to \"yes\" to change the link text from centre-aligned to left-aligned"
},
"type": {
"label": "Type",
"description": "Type of data. Valid values are: \"line\" – a geoline feature from OSM (e.g. a road), \"shape\" – a geoshape feature from OSM (e.g. a state or province), \"shape-inverse\" – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath), \"data\" – a geoJSON data page on Commons (parameter is optional in this case), \"point\" – a point feature (coordinates)",
"type": "string",
"suggested": true
},
"id": {
"aliases": [
"ids"
],
"label": "Wikidata ID",
"description": "Wikidata ID (Q-number) that the OSM feature is tagged with. Separate multiple IDs with a comma.",
"type": "string",
"default": "The current page's Wikidata id (if |from= not set)."
},
"from": {
"label": "From",
"description": "The JSON (.map) page from Commons to display (excluding the Data: prefix)",
"example": "Inner West Light Rail.map",
"suggested": true
},
"title": {
"label": "Title",
"description": "Title of the feature (for features from OSM), displayed when the feature is clicked on.",
"type": "string",
"default": "The title of the page using the template."
},
"description": {
"label": "Description",
"description": "Description of the feature (for features from OSM), displayed when the feature is clicked on; optional",
"type": "string"
},
"raw": {
"aliases": [
"data"
],
"label": "Raw data",
"description": "Raw GeoJSON (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See the \"When to use the raw parameter\" section of the documentation for more information.",
"suggested": true
},
"stroke-color": {
"aliases": [
"stroke-colour"
],
"label": "Stroke (line) colour",
"description": "Colour code for the colour used to draw the feature (for features from OSM).",
"default": "#555555"
},
"stroke-width": {
"label": "Stroke (line) width",
"description": " Width for the lines used to draw the feature (for features from OSM)",
"type": "number",
"default": "5"
},
"coord": {
"label": "Coordinates",
"description": "Coordinates to display for a point feature. Use the Template:Coord template to specify coordinates.",
"default": "If not set, coordinates will be retrieved from Wikidata."
},
"marker": {
"label": "Marker icon",
"description": "Name of Maki marker image to display at the point feature. See https://www.mediawiki.org/wiki/Maps/Icons for options.",
"default": "No icon"
},
"zoom": {
"label": "Zoom level",
"description": "Zoom level, from 1 to 19 (larger numbers zoom in further).",
"type": "number",
"default": "Automatically calculated."
},
"text": {
"label": "Link text",
"description": "Text to display for the link.",
"default": "View map.",
"type": "string"
},
"text2": {
"label": "Link text (2nd link)",
"description": "Text to display for the 2nd link; required if including a 2nd link",
"type": "string"
},
"type2": {
"label": "Type (2nd link)",
"description": "Type of data for the 2nd link. Valid values are: \"line\" – a geoline feature from OSM (e.g. a road), \"shape\" – a geoshape feature from OSM (e.g. a state or province), \"shape-inverse\" – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath), \"data\" – a geoJSON data page on Commons (parameter is optional in this case), \"point\" – a point feature (coordinates).",
"type": "string"
},
"id2": {
"aliases": [
"ids2"
],
"label": "Wikidata ID (2nd link)",
"description": "Wikidata ID (Q-number) that the OSM feature is tagged with. Separate multiple IDs with a comma.",
"type": "string"
},
"title2": {
"label": "Title (2nd link)",
"description": "Title of the feature used for the 2nd link (for features from OSM), displayed when the feature is clicked on.",
"type": "string"
},
"from2": {
"label": "From (2nd link)",
"description": "The JSON (.map) page from Commons to display (excluding the Data: prefix)",
"example": "Inner West Light Rail.map"
},
"description2": {
"label": "Description (2nd link)",
"description": "Description of the feature (for features from OSM), displayed when the feature is clicked on; optional",
"type": "string"
},
"raw2": {
"aliases": [
"data2"
],
"label": "Raw data (2nd link)",
"description": "Raw GeoJSON for the 2nd link (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See the \"When to use the raw parameter\" section of the documentation for more information."
},
"stroke-color2": {
"aliases": [
"stroke-colour2"
],
"label": "Stroke (line) colour (2nd link)",
"description": "Colour code for the colour used to draw the feature (for features from OSM).",
"default": "#555555"
},
"stroke-width2": {
"label": "Stroke (line) width (2nd link)",
"description": " Width for the lines used to draw the feature (for features from OSM)",
"type": "number",
"default": "5"
},
"coord2": {
"label": "Coordinates (2nd link)",
"description": "Coordinates to display for a point feature. Use the Template:Coord template to specify coordinates.",
"default": "If not set, coordinates will be retrieved from Wikidata."
},
"marker2": {
"label": "Marker icon (2nd link)",
"description": "Name of Maki marker image to display at the point feature. See https://www.mediawiki.org/wiki/Maps/Icons for options.",
"default": "No icon"
},
"zoom2": {
"label": "Zoom level (2nd link)",
"description": "Zoom level for the 2nd link, from 1 to 19 (larger numbers zoom in further).",
"type": "number",
"default": "Automatically calculated"
},
"text3": {
"label": "Link text (3rd link)",
"description": "Text to display for the 3rd link; required if including a 3rd link",
"type": "string"
},
"type3": {
"label": "Type (3rd link)",
"description": "Type of data for the 3rd link. Valid values are: \"line\" – a geoline feature from OSM (e.g. a road), \"shape\" – a geoshape feature from OSM (e.g. a state or province), \"shape-inverse\" – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath), \"data\" – a geoJSON data page on Commons (parameter is optional in this case), \"point\" – a point feature (coordinates).",
"type": "string"
},
"id3": {
"aliases": [
"ids3"
],
"label": "Wikidata ID (3rd link)",
"description": "Wikidata ID (Q-number) that the OSM feature is tagged with. Separate multiple IDs with a comma.",
"type": "string"
},
"title3": {
"label": "Title (3rd link)",
"description": "Title of the feature used for the 3rd link (for features from OSM), displayed when the feature is clicked on.",
"type": "string"
},
"from3": {
"label": "From (3rd link)",
"description": "The JSON (.map) page from Commons to display (excluding the Data: prefix)",
"example": "Inner West Light Rail.map"
},
"description3": {
"label": "Description (3rd link)",
"description": "Description of the feature (for features from OSM), displayed when the feature is clicked on; optional",
"type": "string"
},
"raw3": {
"aliases": [
"data3"
],
"label": "Raw data (3rd link)",
"description": "Raw GeoJSON for the 3rd link (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See the \"When to use the raw parameter\" section of the documentation for more information."
},
"stroke-color3": {
"aliases": [
"stroke-colour3"
],
"label": "Stroke (line) colour (3rd link)",
"description": "Colour code for the colour used to draw the feature (for features from OSM).",
"default": "#555555"
},
"stroke-width3": {
"label": "Stroke (line) width (3rd link)",
"description": "Width for the lines used to draw the feature (for features from OSM)",
"type": "number",
"default": "5"
},
"coord3": {
"label": "Coordinates (3rd link)",
"description": "Coordinates to display for a point feature. Use the Template:Coord template to specify coordinates.",
"default": "If not set, coordinates will be retrieved from Wikidata."
},
"marker3": {
"label": "Marker icon (3rd link)",
"description": "Name of Maki marker image to display at the point feature. See https://www.mediawiki.org/wiki/Maps/Icons for options.",
"default": "No icon"
},
"zoom3": {
"label": "Zoom level (3rd link)",
"description": "Zoom level for the 3rd link, from 1 to 19 (larger numbers zoom in further).",
"type": "number",
"default": "Automatically calculated"
},
"text4": {
"label": "Link text (4th link)",
"description": "Text to display for the 4th link; required if including a 4th link",
"type": "string"
},
"type4": {
"label": "Type (4th link)",
"description": "Type of data for the 4th link. Valid values are: \"line\" – a geoline feature from OSM (e.g. a road), \"shape\" – a geoshape feature from OSM (e.g. a state or province), \"shape-inverse\" – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath), \"data\" – a geoJSON data page on Commons (parameter is optional in this case), \"point\" – a point feature (coordinates).",
"type": "string"
},
"id4": {
"aliases": [
"ids4"
],
"label": "Wikidata ID (4th link)",
"description": "Wikidata ID (Q-number) that the OSM feature is tagged with. Separate multiple IDs with a comma.",
"type": "string"
},
"title4": {
"label": "Title (4th link)",
"description": "Title of the feature used for the 4th link (for features from OSM), displayed when the feature is clicked on.",
"type": "string"
},
"from4": {
"label": "From (4th link)",
"description": "The JSON (.map) page from Commons to display (excluding the Data: prefix)",
"example": "Inner West Light Rail.map"
},
"description4": {
"label": "Description (4th link)",
"description": "Description of the feature (for features from OSM), displayed when the feature is clicked on; optional",
"type": "string"
},
"raw4": {
"aliases": [
"data4"
],
"label": "Raw data (4th link)",
"description": "Raw GeoJSON for the 4th link (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See the \"When to use the raw parameter\" section of the documentation for more information."
},
"stroke-color4": {
"aliases": [
"stroke-colour4"
],
"label": "Stroke (line) colour (4th link)",
"description": "Colour code for the colour used to draw the feature (for features from OSM).",
"default": "#555555"
},
"stroke-width4": {
"label": "Stroke (line) width (4th link)",
"description": "Width for the lines used to draw the feature (for features from OSM)",
"type": "number",
"default": "5"
},
"coord4": {
"label": "Coordinates (4th link)",
"description": "Coordinates to display for a point feature. Use the Template:Coord template to specify coordinates.",
"default": "If not set, coordinates will be retrieved from Wikidata."
},
"marker4": {
"label": "Marker image (4th link)",
"description": "Name of Maki marker image to display at the point feature. See https://www.mediawiki.org/wiki/Maps/Icons for options.",
"default": "No icon"
},
"zoom4": {
"label": "Zoom level (4th link)",
"description": "Zoom level for the 4th link, from 1 to 19 (larger numbers zoom in further).",
"type": "number",
"default": "Automatically calculated"
},
"text5": {
"label": "Link text (5th link)",
"description": "Text to display for the 5th link; required if including a 5th link",
"type": "string"
},
"type5": {
"label": "Type (5th link)",
"description": "Type of data for the 5th link. Valid values are: \"line\" – a geoline feature from OSM (e.g. a road), \"shape\" – a geoshape feature from OSM (e.g. a state or province), \"shape-inverse\" – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath), \"data\" – a geoJSON data page on Commons (parameter is optional in this case), \"point\" – a point feature (coordinates).",
"type": "string"
},
"id5": {
"aliases": [
"ids5"
],
"label": "Wikidata ID (5th link)",
"description": "Wikidata ID (Q-number) that the OSM feature is tagged with. Separate multiple IDs with a comma.",
"type": "string"
},
"title5": {
"label": "Title (5th link)",
"description": "Title of the feature used for the 5th link (for features from OSM), displayed when the feature is clicked on.",
"type": "string"
},
"from5": {
"label": "From (5th link)",
"description": "The JSON (.map) page from Commons to display (excluding the Data: prefix)",
"example": "Inner West Light Rail.map"
},
"description5": {
"label": "Description (5th link)",
"description": "Description of the feature (for features from OSM), displayed when the feature is clicked on; optional",
"type": "string"
},
"raw5": {
"aliases": [
"data5"
],
"label": "Raw data (5th link)",
"description": "Raw GeoJSON for the 5th link (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See the \"When to use the raw parameter\" section of the documentation for more information."
},
"stroke-color5": {
"aliases": [
"stroke-colour5"
],
"label": "Stroke (line) colour (5th link)",
"description": "Colour code for the colour used to draw the feature (for features from OSM).",
"default": "#555555"
},
"stroke-width5": {
"label": "Stroke (line) width (5th link)",
"description": "Width for the lines used to draw the feature (for features from OSM)",
"type": "number",
"default": "5"
},
"coord5": {
"label": "Coordinates (5th link)",
"description": "Coordinates to display for a point feature. Use the Template:Coord template to specify coordinates.",
"default": "If not set, coordinates will be retrieved from Wikidata."
},
"marker5": {
"label": "Marker image (5th link)",
"description": "Name of Maki marker image to display at the point feature. See https://www.mediawiki.org/wiki/Maps/Icons for options.",
"default": "No icon"
},
"zoom5": {
"label": "Zoom level (5th link)",
"description": "Zoom level for the 5th link, from 1 to 19 (larger numbers zoom in further).",
"type": "number",
"default": "Automatically calculated"
}
},
"description": "Places a link to a full-page map in a box at the side of the page."
}
</templatedata>