This is the template sandbox page for Template:Maplink (diff). See also the companion subpage for test cases. |
This template is used on approximately 34,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
Preview message: Transclusion count updated automatically (see documentation). |
This template uses Lua: |
This template adds a link, or frame, which will display a map from OpenStreetMap together with specified map data. The map and data can be viewed in a scrollable and zoomable fullscreen window. The map data can come from:
Note:
mapframe
extension tag directly instead of this template, as was done in Special:Diff/970846012. The reason for this is that using the template to call the extension tag will result in the map rendering counting as Lua time, which may result in time exceeded errors.Data:
namespace and ends in .map
– see mw:Help:Map Data for further information.You can use {{Infobox mapframe}} to generate a mapframe map that is suitable for infoboxes, with minimal user input. |
This template is intended to show points as well as linear or polygon features on a map, including (but not limited to):
and more... This template can also be used to display point features on a map, i.e. coordinates.
Basic usage
{{maplink|from=}}
(specify .map data page in from=, excluding Data prefix){{maplink|raw=}}
(specify raw GeoJSON, preferably transcluded from a subpage of Wikipedia:Map data){{maplink|type=line|id=}}
(Wikidata id only required if another article's Wikidata page is to be used){{maplink|type=shape|id=}}
(Wikidata id only required if another article's Wikidata page is to be used){{maplink|type=shape-inverse|id=}}
(Wikidata id only required if another article's Wikidata page is to be used){{coord}}
templates using the |name=
parameter)
|frame=yes
: {{maplink|frame=yes|frame-align=left|type=line|id=Q1094308|text=Mapframe example}}
.|plain=yes
to remove the outer frame: {{maplink|frame=yes|frame-align=left|plain=yes|type=line|id={{get QID|Várkerület}}|frame-width=200|frame-height=250|frame-long=19.1009|frame-lat=47.5001|zoom=9}}
.{{maplink|frame=yes|frame-align=left|frame-width=400|frame-height=300|type=point|id=Q8688|marker=airport|zoom=12 |text=San Francisco International Airport |overlay={{Graph:Street map with marks|width=110|height=90|lat=37.8|lon=-121.8|zoom=6|{ "lat": 37.618, "lon": -122.375 }| minimap=false}}
}}
Parameter set – data page
{{maplink
|display=
|from=
|zoom=
|text=
|icon=
}}
Parameter set – raw data
{{maplink
|display=
|raw= <!-- preferably {{Wikipedia:Map data/subpage}} -->
|zoom=
|text=
|icon=
}}
Parameter set – geoline/geoshape
{{maplink
|display=
|type=
|id=
|title=
|description=
|stroke-color=
|stroke-width=
|zoom=
|text=
|icon=
}}
Parameter set – point features/coordinates
{{maplink
|display=
|type=point
|id=
|title=
|description=
|coord=
|marker=
|zoom=
|text=
|icon=
}}
Parameter set – circles
{{maplink
|display=
|type=circle
|radius= <!-- in metres, alternative parameters available for other units -->
|id=
|title=
|description=
|coord=
|marker=
|zoom=
|text=
|icon=
}}
inline
- Only displays the inline link (you can forego this, as it is the default)title
- Only displays the title linkinline,title
- Displays the inline link as well as the title linktitle,inline
- Same as above1
to 19
(larger numbers zoom in further); default is automatically determined by the map, unless the only feature is a single point.Mapframe parameters (only work with inline display)
left
, center
, or right
; default is right
300
200
|frame-coordinates={{Coord|12.34|S|56.78|W}}
). If not set, coordinates will be retrieved from Wikidata.|frame-coordinates=
or |frame-coord=
is set)|frame-coordinates=
or |frame-coord=
is set)|coord=
(if set), or|id=
parameter, or for the page the template is placed on)|overlay=[[File:Example.svg|140x140px]]
or|overlay={{maplink|frame=yes|plain=yes|frame-width=100|frame-height=100|type=shape|id={{get QID|French submarine Ariane (1914)}}|frame-align=center}}
or|overlay={{Graph:Street map with marks|width=100|height=100|lat=37.8|lon=-122.4|zoom=6|{ "lat": 37.8, "lon": -122.4 }|minimap=false}}
left
or right
; default is right
top
or bottom
; default is bottom
10
for a 10 pixel gap3px solid black
; default is 1px solid white
. The colour can be any web color name or hex code.Multiple features can be displayed on a single map. For each additional feature, add a sequential number to the end of the parameter name. For example, the second uses parameters like |type2=
, |id2=
, etc., the third feature |type3=
, |id3=
, etc., and so on. Higher numbers are drawn on top.
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)named
– all named coordinates in an page or section ({{coord}}
templates with |name=
parameter)circle
– a circle centred on a point's coordinates|from=
not set).data
or omitted: The JSON (.map) file from Commons to display (excluding the Data:
prefix)named
: Page name, or name#section, to get named coordinates from. If omitted, or specified as just #section, then current page will be used.#ff0000
(red)6
0
(fully transparent) and 1
(fully opaque); default is 1
#000000
(black). Note that a semi-transparent version of the specified color will be used by default, allowing the map below to still be seen.0
(fully transparent) and 1
(fully opaque); default is 0.5
|coord={{Coord|12.34|S|56.78|W}}
). If not set, coordinates will be retrieved from Wikidata.5E74F3
( )small
, medium
(default) or large
.32
. Higher numbers will result in a smoother circle but use more Lua processing resources.Adds a link, or frame, which will display map data
Parameter | Description | Type | Status | |
---|---|---|---|---|
display | display | How the template is displayed
| Unknown | optional |
text | text | Text to display for the link (or caption if using mapframe)
| Line | optional |
icon | icon | Set to "no" to turn off the icon that appears next to the link | Boolean | optional |
zoom | zoom | Zoom level, from 1 to 19 (larger numbers zoom in further); default is automatically determined by the map, unless the only feature is a single point. | Number | optional |
An option for Template:Switcher-style switching of multiple mapframes, where specified parameters like zoom, or frame coordinates, or a shape's item id are switched between different values. When using, ensure the number of values in each list are the same.
Instructions:
,
, or ;
if the labels contain commas, or ###
if the labels contain semi-colons. Each label will be displayed with a prefix of "Show ".
|switch=zoomed out, zoomed mid, zoomed in
,
or ;
or ###
|zoom=SWITCH:4,9,14
|switch=
.{{mapframe|frame=yes|type=point|id=Q100|text=Boston|zoom=SWITCH:4,9,14|switch=zoomed out, zoomed mid, zoomed in}}
Multiple features allow you to:
{{Maplink|frame=yes
|type=shape|id=Q3495894|title=Shape|description=Description of shape
|type2=line|id2=Q1318331|title2=Line|description2=Description of line
|type3=point|coord3={{coord|32|S|116|E}}|title3=Point|description3=Description of point
}}
{{Maplink|frame=yes|plain=yes|frame-width=250|frame-height=280|zoom=6|frame-lat=29.185|frame-long=76.225
|type=shape-inverse|id=Q1174|title=Haryana
|type2=point|id2=Q200663|stroke-width=3|title2=Faridabad
}}
Mapframes can be included in infoboxes. Using |plain=yes
to remove the outer frame is recommended.
For simple cases with a single feature, {{infobox mapframe}}
can be used instead (see that template's documentation for details).
Mitchell Freeway | |
---|---|
Map of Perth's northern suburbs with Mitchell Freeway highlighted in red | |
Type | Freeway |
{{Infobox Australian road
| location = {{maplink |type=line |frame=yes |plain=yes |frame-align=center |frame-lat=-31.8262 |frame-long=115.7877 |zoom=9}}
... (other parameters omitted) ...
}}
The "raw" parameter allows the same inputs as the full <maplink> function. It allows you to:
See mw:Help:Extension:Kartographer for instructions.
{{maplink|raw={{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}|text=Route map}}
(Link to GeoJSON data subpage: Wikipedia:Map data/Main Roads Western Australia/Forrest Highway)
{{maplink|frame=yes|text=Ten countries|raw={
"type": "ExternalData",
"service": "geoshape",
"query": "
SELECT * WHERE {
?id wdt:P463 wd:Q1065 .
} LIMIT 10
"}
|frame-width=600|frame-height=400|frame-lat=25|frame-long=10|zoom=1
}}
{{maplink|frame=yes|raw={
"type": "ExternalData",
"service": "geoshape",
"query": "
SELECT ?id ?head
(SAMPLE(?img) as ?img_)
(min(?partyId) as ?party)
(if(?party = '0', '#800000', if(?party = '1', '#000080', '#008000')) as ?fill)
(concat('[[', substr(str(?link),31,500), '{{!}}', ?headLabel, ']]') as ?title)
(concat(?stateLabel, '\\n', '[[File:', substr(str(?img_), 52, 500), '{{!}}200px]]') as ?description)
WHERE {
?id wdt:P31 wd:Q35657 .
?id wdt:P6 ?head .
?head wdt:P102 ?party .
BIND(if(?party = wd:Q29468, '0', if(?party = wd:Q29552, '1', '2')) as ?partyId)
SERVICE wikibase:label {
bd:serviceParam wikibase:language 'en' .
?head rdfs:label ?headLabel .
?id rdfs:label ?stateLabel .
}
OPTIONAL {
?head wdt:P18 ?img .
}
?link schema:about ?head .
?link schema:isPartOf <https://en.wikipedia.org/> .
} GROUP BY ?id ?head ?headLabel ?link ?stateLabel
"}|frame-width=600|frame-height=400|frame-lat=52|frame-long=-110|zoom=3}}
|raw=
parameter)|raw=
parameter won't work because the curly brace to close the GeoJSON is adjacent to the curly braces to close the template: {{Maplink|raw= {"type": "ExternalData","service": "geoshape","ids": "Q13518258"}}}
<mapframe>...</mapframe>
tags, then it should be reported on Phabricator (you can log in with you Wikipedia account). See mw:How to report a bug for instructions (for the tags, use Maps). (Alternatively, you can try mw:Help talk:Extension:Kartographer)|raw=
parameter is showing error messages of "The time allocated for running scripts has expired." What can be done?