Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Loncat ke navigasi Loncat ke pencarian

<mapframe zoom="9" text="Mapframe" height="200" latitude="35.90" longitude="-106.56" width="300">{"properties":{"stroke-width":6,"stroke":"#ff0000","title":"Maplink"},"type":"ExternalData","title":"ecos.fws.gov/Endangered habitat 58938/Plethodon neomexicanus.map","service":"page"}</mapframe> MaplinkMaplink

[lihat] [sunting] [versi terdahulu] [hapus singgahan] Ikon dokumentasi Dokumentasi templat

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


Uses[sunting sumber]

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[sunting sumber]

Basic usage

<mapframe height="200" text="Mapframe example" width="300">{"properties":{"stroke-width":6,"stroke":"#ff0000","title":"Maplink"},"type":"ExternalData","service":"geoline","ids":"Q1094308"}</mapframe>

  • Additional parameters are available to customise the displayed map.

<mapframe zoom="8" frameless="1" height="250" latitude="47.5001" longitude="19.1009" width="200">{"properties":{"stroke-width":6,"stroke":"#ff0000","title":"Maplink"},"type":"ExternalData","service":"geoline","ids":"Q1094308"}</mapframe>

Full parameter set – data page


Full parameter set – raw data

|raw= <!-- preferably {{Wikipedia:Map data/subpage}} -->

Full parameter set – geoline/geoshape


Full parameter set – point features/coordinates


Parameters[sunting sumber]

For overall display[sunting sumber]

How the template is displayed. Valid values are:
inline - Only displays the inline link (you can forego this, as it is the default)
title - Only displays the title link
inline,title - Displays the inline link as well as the title link
title,inline - Same as above
Text to display for the link (or caption if using mapframe); default is "Map"
Set to "no" to turn off the icon that appears next to the link
Zoom level, from 1 to 19 (larger numbers zoom in further); default is automatically determined by the map
(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)

Set to "yes" to show a map frame instead of a link
Set to "yes" to show just the map without the surrounding frame, and without a caption (text parameter will be ignored)
Alignment with respect to the page: left, center, or right; default is right
Width of the map frame, default is 300
Height of the map frame, default is 200
(or frame-lat)
Optional - alternate latitude coordinate for initial placement of map
(or frame-long)
Optional - alternate longitude coordinate for initial placement of map
If frame latitude and longitude are not set by parameters, then coordinates in |coord= will be used (if set), or coordinates will be retrieved from Wikidata (if available, for either the item specified in |id= parameter or for the page the template is placed on)

Raw GeoJSON[sunting sumber]

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.

For each feature[sunting sumber]

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.

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)
(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 |from= not set).
The JSON (.map) file from Commons to display (excluding the Data: prefix)
Title of the feature (for features from OSM), displayed when the feature is clicked on; default is the page title
Description of the feature (for features from OSM), displayed when the feature is clicked on; optional
(or stroke-colour)
Color code for the color used to draw the feature (for features from OSM); default is #ff0000 (red)
Width for the lines used to draw the feature (for features from OSM); default is 6
Coordinates to display for a point feature. Use {{Coord}} template to specify coordinates. If not set, coordinates will be retrieved from Wikidata.
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.
(or marker-colour)
Color code (Hex triplet) specifying marker background color. Default is 5E74F3 (    )

Examples and tips[sunting sumber]

Multiple features[sunting sumber]

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

<mapframe height="200" text="Map" width="300">[ {"properties":{"stroke-width":6,"stroke":"#ff0000","title":"Shape","description":"Description of shape"},"type":"ExternalData","service":"geoshape","ids":"Q3495894"}, {"properties":{"stroke-width":6,"stroke":"#ff0000","title":"Line","description":"Description of line"},"type":"ExternalData","service":"geoline","ids":"Q1318331"}, {"type":"Feature","geometry":{"coordinates":[116,-32],"type":"Point"},"properties":{"description":"Description of point","title":"Point","marker-color":"5E74F3"}} ]</mapframe>

|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

<mapframe zoom="6" frameless="1" height="280" latitude="29.185" longitude="76.225" width="250">[ {"properties":{"stroke-width":3,"stroke":"#ff0000","title":"Haryana"},"type":"ExternalData","service":"geomask","ids":"Q1174"}, {"type":"Feature","geometry":{"coordinates":[77.3,28.416666666667],"type":"Point"},"properties":{"title":"Faridabad","marker-color":"5E74F3"}} ]</mapframe>


Infoboxes[sunting sumber]

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
Arah umum {{{direction}}}
Dari {{{start}}}
Ke {{{finish}}}
{{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[sunting sumber]

The "raw" parameter allows the same inputs as the full <maplink> 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[sunting sumber]

<maplink>: Tidak dapat memilah JSON: Kesalahan sintaks
{{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)

Raw Wikidata query example[sunting sumber]

<mapframe zoom="3" text="Map" height="400" latitude="52" longitude="-110" width="600">{ "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('', ?headLabel, '') as ?title) (concat(?stateLabel, '\\n', '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 "}</mapframe>

  "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)
  ?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 .
    ?head wdt:P18 ?img .
  ?link schema:about ?head .
  ?link schema:isPartOf <https://en.wikipedia.org/> .
} GROUP BY ?id ?head ?headLabel ?link ?stateLabel

Gotchas[sunting sumber]

  • 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 |raw= parameter)
  • The following code utilising the |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"}}}
To fix it, put a space before the two template braces or move them to a separate line.

Redirects[sunting sumber]

  • {{Map link}}
  • {{Mapframe}}

See also[sunting sumber]