வார்ப்புரு:Maplink/doc
{{Documentation subpage}}
 &lt;includeonly&gt;{{template shortcut|Mapframe}}&lt;/includeonly&gt;
 {{Lua|Module:Mapframe}}
 {{Uses Wikidata|P625}}
 {{Sister project
 |image=[[File:Openstreetmap logo.svg|40x40px]]
 |text=This template uses the [[OpenStreetMap]] tag:
 *'''''[https://wiki.openstreetmap.org/wiki/Key:wikidata wikidata]''''' (see [https://wiki.openstreetmap.org/wiki/Talk:Key:wikidata talk]; [https://taginfo.openstreetmap.org/keys/wikidata taginfo])
 }}
 &lt;!--{{High-use|2960}}--&gt;
 &lt;!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE --&gt;
 
 This template adds a link, or frame, which will display map 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 [[c:|Commons]], create a page that is in the &lt;code&gt;Data:&lt;/code&gt; namespace and ends in &lt;code&gt;.map&lt;/code&gt; – 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.
 
 ==Uses==
 This template is intended for linear or polygon features, including (but not limited to):
 *Roads
 *Rivers
 *Subway or train lines
 *Ship courses
 *Flight paths
 *Explorers journeys
 *Animal habitats
 *Countries and their subdvisions
 and more...
 This template can also be used to display point features on a map, i.e. coordinates.
 
 ==Usage==
 Basic usage
 *{{maplink|from=ecos.fws.gov/Endangered habitat 58938/Plethodon neomexicanus.map|text=Data page}} on Commons {{small|1=(e.g. [[c:Data:ecos.fws.gov/Endangered habitat 58938/Plethodon neomexicanus.map|Data:ecos.fws.gov/Endangered habitat 58938/Plethodon neomexicanus.map]])}}:
 *:&lt;code&gt;&lt;nowiki&gt;{{maplink|from=}}&lt;/nowiki&gt;&lt;/code&gt; (specify .map data page in from=, excluding Data prefix)
 *{{maplink|raw={{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}|text=Raw GeoJSON data}} {{small|1=(e.g. &lt;nowiki&gt;{{&lt;/nowiki&gt;[[Wikipedia:Map data/Main Roads Western Australia/Forrest Highway]]&lt;nowiki&gt;}}&lt;/nowiki&gt;)}}:
 *:&lt;code&gt;&lt;nowiki&gt;{{maplink|raw=}}&lt;/nowiki&gt;&lt;/code&gt; (specify raw GeoJSON, preferably transcluded from a subpage of [[Wikipedia:Map data]])
 *{{maplink|type=line|id=Q1094308|text=Line of a border or a linear feature}} from OSM:
 *:&lt;code&gt;&lt;nowiki&gt;{{maplink|type=line|id=}}&lt;/nowiki&gt;&lt;/code&gt; (Wikidata id only required if another article's Wikidata page is to be used)
 *{{maplink|type=shape|id=Q1094308|text=Shape}} from OSM:
 *:&lt;code&gt;&lt;nowiki&gt;{{maplink|type=shape|id=}}&lt;/nowiki&gt;&lt;/code&gt; (Wikidata id only required if another article's Wikidata page is to be used)
 *{{maplink|type=shape-inverse|id=Q1094308|text=Inverted shape}} from OSM: 
 *:&lt;code&gt;&lt;nowiki&gt;{{maplink|type=shape-inverse|id=}}&lt;/nowiki&gt;&lt;/code&gt; (Wikidata id only required if another article's Wikidata page is to be used)
 *{{maplink|type=point|id=Q1094308|text=Point feature}} (coordinates):
 *:...from Wikidata:&lt;br/&gt;&lt;code&gt;&lt;nowiki&gt;{{maplink|type=point|id=}}&lt;/nowiki&gt;&lt;/code&gt; (Wikidata id only required if another article's Wikidata page is to be used)
 *:...from specified coordinates:&lt;br/&gt;&lt;code&gt;&lt;nowiki&gt;{{maplink|type=point|coord=}}&lt;/nowiki&gt;&lt;/code&gt; (specify coordinates using {{tl|Coord}} template)
 *To show in a frame, add the parameter {{para|frame|yes}}.
 {{maplink|frame=yes|type=line|id=Q1094308|text=Mapframe example}}
 {{-}}
 *Additional parameters are available to customise the displayed map.
 {{maplink|frame=yes|plain=yes|type=line|id=Q1094308|frame-width=200|frame-height=250|frame-long=19.1009|frame-lat=47.5001|zoom=8}}
 {{-}}
 Full parameter set – data page
 &lt;pre&gt;
 {{maplink
 |display=
 |from=
 |zoom=
 |text=
 |icon=
 }}
 &lt;/pre&gt;
 
 Full parameter set – raw data
 &lt;pre&gt;
 {{maplink
 |display=
 |raw= &lt;!-- preferably {{Wikipedia:Map data/subpage}} --&gt;
 |zoom=
 |text=
 |icon=
 }}
 &lt;/pre&gt;
 
 Full parameter set – geoline/geoshape
 &lt;pre&gt;
 {{maplink
 |display=
 |type=
 |id=
 |title=
 |description=
 |stroke-color=
 |stroke-width=
 |zoom=
 |text=
 |icon=
 }}
 &lt;/pre&gt;
 
 Full parameter set – point features/coordinates
 &lt;pre&gt;
 {{maplink
 |display=
 |type=point
 |id=
 |title=
 |description=
 |coord=
 |marker=
 |zoom=
 |text=
 |icon=
 }}
 &lt;/pre&gt;
 
 ==Parameters==
 ===For overall display===
 ;display
 :How the template is displayed. Valid values are:
 ::&lt;code&gt;inline&lt;/code&gt; - Only displays the inline link (you can forego this, as it is the default)
 ::&lt;code&gt;title&lt;/code&gt; - Only displays the title link
 ::&lt;code&gt;inline,title&lt;/code&gt; - Displays the inline link as well as the title link
 ::&lt;code&gt;title,inline&lt;/code&gt; - Same as above
 ;text
 :Text to display for the link (or caption if using mapframe); default is &quot;Map&quot;
 ;icon
 :Set to &quot;no&quot; to turn off the icon that appears next to the link
 ;zoom
 :Zoom level, from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;19&lt;/code&gt; (larger numbers zoom in further); default is automatically determined by the map&lt;br/&gt;{{resize|(Note that automatically determined zoom level does not work for mapframe maps except when previewing the page – see [[phab:T193455]])}}
 Mapframe parameters (only work with inline display)
 ;frame
 :Set to &quot;yes&quot; to show a map frame instead of a link
 :;plain
 ::Set to &quot;yes&quot; to show just the map without the surrounding frame, and without a caption ('''text''' parameter will be ignored)
 :;frame-align
 ::Alignment with respect to the page: &lt;code&gt;left&lt;/code&gt;, &lt;code&gt;center&lt;/code&gt;, or &lt;code&gt;right&lt;/code&gt;; default is &lt;code&gt;right&lt;/code&gt; 
 :;frame-width
 ::Width of the map frame, default is &lt;code&gt;300&lt;/code&gt;
 :;frame-height
 ::Height of the map frame, default is &lt;code&gt;200&lt;/code&gt;
 :;frame-coordinates
 ::''(or '''frame-coord''')''
 ::Optional - alternate coordinates for initial placement of map. Use {{tl|Coord}} template to specify coordinates {{small|1=(e.g. {{para|frame-coordinates|2=&lt;nowiki&gt;{{Coord|12.34|S|56.78|W}}&lt;/nowiki&gt;}})}}. If not set, coordinates will be retrieved from Wikidata.
 :;frame-latitude
 ::''(or '''frame-lat''')''
 ::''(ignored if ''{{para|frame-coordinates}}'' or ''{{para|frame-coord}}'' is set)''
 ::Optional - alternate latitude coordinate for initial placement of map. 
 :;frame-longitude
 ::''(or '''frame-long''')''
 ::''(ignored if ''{{para|frame-coordinates}}'' or ''{{para|frame-coord}}'' is set)''
 ::Optional - alternate longitude coordinate for initial placement of map.
 :If frame latitude and longitude are not set by parameters, then frame coordinates can be determined automatically: either from the point feature specified in {{para|[[#coord|coord]]}} (if set), or coordinates will be retrieved from Wikidata (if available – for either the item specified in {{para|id}} parameter, or for the page the template is placed on)
 
 ===Raw GeoJSON===
 ;raw
 :Raw GeoJSON (preferably transcluded from a subpage of [[Wikipedia:Map data]]) as well as &lt;nowiki&gt;&lt;maplink&gt;&lt;/nowiki&gt; functionality not available via the other parameters. [[#The raw parameter|See below]] for more information.
 
 ===For each feature===
 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 {{para|type2}}, {{para|id2}}, etc., the third feature {{para|type3}}, {{para|id3}}, etc., and so on.
 ;type
 :Type of data. Valid values are:
 ::&lt;code&gt;line&lt;/code&gt; – a geoline feature from OSM (e.g. a road)
 ::&lt;code&gt;shape&lt;/code&gt; – a geoshape feature from OSM (e.g. a state or province)
 ::&lt;code&gt;shape-inverse&lt;/code&gt; – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath)
 ::&lt;code&gt;data&lt;/code&gt; – a geoJSON data page on Commons (parameter is optional in this case)
 ::&lt;code&gt;point&lt;/code&gt; – a point feature (coordinates)
 ;id
 :''(or '''ids''')''
 :Wikidata id (Q-number) of the point feature, Wikidata id that the OSM line/shape feature is tagged with. Separate multiple ids with a comma. Defaults to the current page's Wikidata id (if {{para|from}} not set).
 ;from
 :The JSON (.map) file from Commons to display (excluding the &lt;code&gt;Data:&lt;/code&gt; prefix)
 ;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
 ;stroke-color
 :''(or '''stroke-colour''')''
 :Color code for the color used to draw the feature (for features from OSM); default is &lt;code&gt;#ff0000&lt;/code&gt; (red)
 ;stroke-width
 :Width for the lines used to draw the feature (for features from OSM); default is &lt;code&gt;6&lt;/code&gt;
 ;{{anchor|coord}}coord
 :Coordinates to display for a point feature. Use {{tl|Coord}} template to specify coordinates  {{small|1=(e.g. {{para|coord|2=&lt;nowiki&gt;{{Coord|12.34|S|56.78|W}}&lt;/nowiki&gt;}})}}. 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. If not set, a plain marker will be shown without an image. 
 ;marker-color
 :''(or '''marker-colour''')''
 :Color code ([[Web colors#Hex triplet|Hex triplet]]) specifying marker background color. Default is &lt;code&gt;5E74F3&lt;/code&gt; ({{Color box|#5E74F3}})
 
 ==Examples and tips==
 ===Multiple features===
 Multiple features allow you to:
 *Use external data from both Wikimedia Commons and OpenStreetMap together
 *Apply different styles to different external data features from OpenStreetMap
 *Include multiple links to external data from Wikimedia Commons
 
 {{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
 }}
 &lt;pre&gt;{{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
 }}
 &lt;/pre&gt;
 {{-}}
 
 {{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
 }}
 &lt;pre&gt;
 {{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
 }}
 &lt;/pre&gt;
 {{-}}
 
 ===Infoboxes===
 Mapframes can be included in infoboxes. Using {{para|plain|yes}} to remove the outer frame is recommended.
 
 For simple cases with a single feature, {{tlx|infobox mapframe}} can be used instead (see that template's documentation for details).
 {{Infobox Australian road
 | road_name    = Mitchell Freeway
 | location     = {{maplink |type=line |frame=yes |plain=yes |frame-align=center |frame-lat=-31.8262 |frame-long=115.7877 |zoom=9 |id=Q1939502}}
 | loc_caption  = Map of Perth's northern suburbs with Mitchell Freeway highlighted in red
 | type         = freeway
 | show_links   = no
 }}
 
 &lt;pre&gt;
 {{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)  ...
 }}
 &lt;/pre&gt;
 {{-}}
 
 === The raw parameter ===
 The &quot;raw&quot; parameter allows the same inputs as the full &lt;nowiki&gt;&lt;maplink&gt;&lt;/nowiki&gt; function. It allows you to:
 *Use GeoJSON data directly
 *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
 See [[mw:Help:Extension:Kartographer]] for instructions.
 ====Raw GeoJSON example====
 {{maplink|raw={{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}|text=Route map}}
 &lt;pre&gt;
 {{maplink|raw={{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}|text=Route map}}
 &lt;/pre&gt;
 (Link to GeoJSON data subpage: [[Wikipedia:Map data/Main Roads Western Australia/Forrest Highway]])
 ====Raw Wikidata query example====
 {{maplink|frame=yes|raw={
   &quot;type&quot;: &quot;ExternalData&quot;,
   &quot;service&quot;: &quot;geoshape&quot;,
   &quot;query&quot;: &quot;
 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 &lt;https://en.wikipedia.org/&gt; .
 } GROUP BY ?id ?head ?headLabel ?link ?stateLabel
 &quot;}|frame-width=600|frame-height=400|frame-lat=52|frame-long=-110|zoom=3}}
 &lt;pre style=min-width:30em&gt;
 {{maplink|frame=yes|raw={
   &quot;type&quot;: &quot;ExternalData&quot;,
   &quot;service&quot;: &quot;geoshape&quot;,
   &quot;query&quot;: &quot;
 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 &lt;https://en.wikipedia.org/&gt; .
 } GROUP BY ?id ?head ?headLabel ?link ?stateLabel
 &quot;}|frame-width=600|frame-height=400|frame-lat=52|frame-long=-110|zoom=3}}
 &lt;/pre&gt;
 {{-}}
 
 ===Gotchas===
 *When retrieving lines or shapes from OSM, you can't style the fill color or the opacity level of fills or strokes (unless you use the {{para|raw}} parameter)
 *The following code utilising the {{para|raw}} parameter won't work because the curly brace to close the GeoJSON is adjacent to the curly braces to close the template:
 &lt;pre&gt;{{Maplink|raw= {&quot;type&quot;: &quot;ExternalData&quot;,&quot;service&quot;: &quot;geoshape&quot;,&quot;ids&quot;: &quot;Q13518258&quot;}}}&lt;/pre&gt;
 :To fix it, put a space before the two template braces or move them to a separate line.
 
 == Redirects ==
 * {{tlf|Map link}}
 * {{tlf|Mapframe}}
 
 == See also ==
 *[[Template:Mapbox]] - a derivative of this template that puts the link inside a right-aligned box
 *[[Template:Attached KML]]
 
 &lt;includeonly&gt;{{sandbox other||
 &lt;!-- Categories below this line, please; interwikis at Wikidata --&gt;