Template:Infobox mapframe/doc

From Talking Heads Wiki
Jump to navigation Jump to search

This template generates a mapframe map, suitable for infoboxes, with minimal user input. This template only works with single features (points, lines, or shapes); use {{maplink}} if more advanced options, such as displaying multiple features, are required.

If coordinates are not supplied, they will be fetched from the page's Wikidata item. In such cases, if |point= is not set, then a point feature marker is displayed at those coordinates unless the Wikidata item has an Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P402) specified.

Usage

Note: When in mainspace, parameter |id= is not required (except to use a different page's data)

Basic

<syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> When used without parameters, or with only |id=, the map will display either a shape, line, or point feature, depending on the data available on Wikidata and OpenStreetMap.

Basic usage examples

Point feature (Wikidata coordinates): <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value). Line feature: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value). Shape feature: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).

Using specified coordinates instead of Wikidata

Point feature only, no shapes or lines: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Point feature and shape/line feature if available: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight>

Specify coordinates using the {{Coord}} templates, e.g. |coord={{Coord|32.1|S|116.2|E}}

  • If |coord= is specified, then by default only that coordinate will be displayed (no line or shape features)
  • If |coord= is specified and |wikidata=yes is used, then those coordinate will be displayed, along with any line or shape features linked to the Wikidata item.
Specified coordinates examples

Point feature (with coordinates specified, no shape/line feature from Wikidata item): <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value). Point feature (with coordinates specified, along with shape/line feature from Wikidata item): <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).

Customizing which features are displayed

Inverse shape

<syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Replace the shape with an inverse-shape (geomask) by setting |shape=inverse

Inverse shape example

<syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).

Turn point marker on or off

Force point marker to be displayed: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Prevent point marker from being displayed: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight>

Turn shape feature off

Prevent shape feature from being displayed: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight>

Turn line feature off

Prevent line feature from being displayed: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight>

Show a geomask from a related Wikidata item

<syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Set |geomask= to a Wikidata item id (Q-number), or property id (P-number) such as Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P17)

Geomask examples

Use the item linked from the Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P17) statement as a geomask: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value). Use the item Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (Q1199) as a geomask: <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).

Determine zoom from object length or area

Use |length_km= or |length_mi= or |area_km2= or |area_mi2=

Zoom from length/area examples

Determine zoom from object length in kilometres or miles <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value). Determine zoom from object area in square kilometres or square miles <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> <syntaxhighlight lang="wikitext">Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).</syntaxhighlight> Lua error in Module:Infobox_mapframe at line 40: attempt to index field 'wikibase' (a nil value).

Parameters

All parameters are optional.

  • Basic parameters:
    • id – Id (Q-number) of Wikidata item to use. Default: item for current page
    • coordinates or coord – Coordinates to use, instead of any on Wikidata. Use the {{Coord}} template, e.g. |coord={{Coord|12.34|N|56.78|E}}. Default: coordinates from Wikidata
    • wikidata – Set to <syntaxhighlight lang="text" class="" id="" style="" inline="1">yes</syntaxhighlight> to show shape/line features from the wikidata item, if any, when |coord= is set. Default: not specified
  • Customise which features are displayed:
    • shape – Turn off display of shape feature by setting to <syntaxhighlight lang="text" class="" id="" style="" inline="1">none</syntaxhighlight>. Use an inverse shape (geomask) instead of a regular shape by setting to <syntaxhighlight lang="text" class="" id="" style="" inline="1">inverse</syntaxhighlight>. Default: not specified
    • point – Turn off display of point feature by setting to <syntaxhighlight lang="text" class="" id="" style="" inline="1">none</syntaxhighlight>. Force point marker to be displayed by setting to <syntaxhighlight lang="text" class="" id="" style="" inline="1">on</syntaxhighlight>. Default: not specified
    • line – Turn off display of line feature by setting to <syntaxhighlight lang="text" class="" id="" style="" inline="1">none</syntaxhighlight>. Default: not specified
    • geomask – Wikidata item to use as a geomask (everything outside the boundary is shaded darker). Can either be a specific Wikidata item (Q-number), or a property that specifies the item to use (e.g. P17 for Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P17), P131 for Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P131)). Default: not specified
    • switcher – set to <syntaxhighlight lang="text" class="" id="" style="" inline="1">auto</syntaxhighlight> or <syntaxhighlight lang="text" class="" id="" style="" inline="1">geomasks</syntaxhighlight> or <syntaxhighlight lang="text" class="" id="" style="" inline="1">zooms</syntaxhighlight> to enable Template:Switcher-style switching between multiple mapframes. Default: not specified
      • <syntaxhighlight lang="text" class="" id="" style="" inline="1">auto</syntaxhighlight> – switch geomasks found in Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P276) and Lua error in Module:Wd at line 621: attempt to index field 'wikibase' (a nil value). (P131) statements on the page's Wikidata item, searching recursively. E.g. an item's city, that city's state, and that state's country.
      • <syntaxhighlight lang="text" class="" id="" style="" inline="1">geomasks</syntaxhighlight> – switch between the geomasks specified as a comma-separated list of Wikidata items (Q-numbers) in the geomask parameter
      • <syntaxhighlight lang="text" class="" id="" style="" inline="1">zooms</syntaxhighlight> – switch between "zoomed in"/"zoomed midway"/"zoomed out", where "zoomed in" is the default zoom (with a minimum of <syntaxhighlight lang="text" class="" id="" style="" inline="1">3</syntaxhighlight>), "zoomed out" is <syntaxhighlight lang="text" class="" id="" style="" inline="1">1</syntaxhighlight>, and "zoomed midway" is the average
  • Other optional parameters:
    • frame-width or width – Frame width. Default: 270
    • frame-height or height – Frame height. Default: 200
    • shape-fill – Color used to fill shape features. Default: #606060
    • shape-fill-opacity – Opacity level of shape fill, a number between 0 and 1. Default: 0.5
    • stroke-color or stroke-colour – Color of line features, and outlines of shape features. Default: #ff0000
    • stroke-width – Width of line features, and outlines of shape features; default is "5". Default: 5
    • marker – Marker symbol to use for coordinates; see mw:Help:Extension:Kartographer/Icons for options. Default: not specified (i.e. blank)
      • Can also be set to <syntaxhighlight lang="text" class="" id="" style="" inline="1">blank</syntaxhighlight> to override any default marker symbol
    • marker-color or marker-colour – Background color for the marker. Default: #5E74F3
    • geomask-stroke-color or geomask-stroke-colour – Color of outline of geomask shape. Default: #555555
    • geomask-stroke-width – Width of outline of geomask shape. Default: 2
    • geomask-fill – Color used to fill outside geomask features. Default: #606060
    • geomask-fill-opacity – Opacity level of fill outside geomask features, a number between 0 and 1. Default: 0.5
    • zoom – Set the zoom level, from "1" (map of earth) to "18" (maximum zoom in), to be used if the zoom level cannot be determined automatically from object length or area. Default: 10
    • length_km or length_mi or area_km2 or area_mi2 – Determine zoom level by passing in object's length (in kilometres or miles) or area (in square kilometres or square miles). Default: not specified
    • frame-coordinates or frame-coord – Alternate latitude and longitude coordinates for initial placement of map, using {{coord}}. Default: derived from item coordinates
  • Deprecated parameters
    • frame-lat or frame-latitude – Alternate latitude coordinate for initial placement of map; default is derived from item coordinates
    • frame-long or frame-longitude – Alternate longitude coordinate for initial placement of map; default is derived from item coordinates

Examples for use within templates

Infobox hospital

{{Infobox hospital}} (as of 5 October 2019) <syntaxhighlight lang="wikitext">

image3 = Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value). caption3 =

</syntaxhighlight>

Infobox power station

{{Infobox power station}} (as of 2 April 2019): <syntaxhighlight lang="wikitext">| image2 = Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).

caption2 =

</syntaxhighlight>

Infobox Australian road

{{Infobox Australian road}} (as of 5 October 2019): <syntaxhighlight lang="wikitext">

data3 = Lua error in Module:Infobox_mapframe at line 185: attempt to index field 'wikibase' (a nil value).

</syntaxhighlight>

FAQ

Q1: Where to file a bug report when there is a problem with the base map? (e.g. a missing lake)
A1: If the problem also occurs on OpenStreetMap, it needs to be fixed there. If the problem is only on Wikimedia's maps, it can 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)
Q2: Where to report other bugs or problems with the maps?
A2: This may be a problem with the Wikipedia module, or it may be an underlying software bug (there are lots of those).
Q3: Why does the thumbnail map render as a static image when viewing pages, but is interactive when editing pages?
A3: On Wikipedia, and most wikis other than Wikivoyage, the emdeded thumbnail is a static map, and the full screen map needs to be opened before the map can be zoomed or panned. This is for for performance reasons, and to present some content if javascript is disabled, and for printing.
That preview mode shows an interactive map is a bug, phab:T203863 (and also a performance issue). Further explanation can be found in the comments on phab:T202793.
Q4: Why is a line or shape feature from OpenStreetMap not being shown?
A4: There are several possible causes:
Q5: Why are line, shape, or point features are not shown after editing or adding a map, even though they were shown in the page preview?
A5: This is a bug related to generating thumbnail map images. It should fix itself in an hour or two. See phab:T269984 for details.
Q6: A page using mapframe's |raw= parameter is showing error messages of "The time allocated for running scripts has expired." What can be done?
A6: If the amount of raw data to be processed is too large, that timeout message may be shown. You can try moving the raw data to Commons (example) or replacing the mapframe template with the equivalent wikitext using Special:ExpandTemplates (example)

Template data

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Infobox mapframe in articles based on its TemplateData.

TemplateData for Infobox mapframe

parameters

<templatedata> { "params": { "mapframe": { "aliases": [ "alias" ], "label": "mapframe", "description": "=yes will create a map", "type": "boolean", "default": "no" }, "mapframe-caption": {}, "mapframe-custom": {}, "qid": {}, "coordinates": {}, "mapframe-wikidata": {}, "mapframe-shape": {}, "mapframe-point": {}, "mapframe-line": {}, "mapframe-geomask": {}, "mapframe-switcher": {}, "mapframe-frame-width": {}, "mapframe-frame-height": {}, "mapframe-shape-fill": {}, "mapframe-shape-fill-opacity": {}, "mapframe-stroke-color": {}, "mapframe-stroke-width": {}, "mapframe-marker": {}, "mapframe-marker-color": {}, "mapframe-geomask-stroke-color": {}, "mapframe-geomask-stroke-width": {}, "mapframe-geomask-fill": {}, "mapframe-geomask-fill-opacity": {}, "mapframe-zoom": {}, "mapframe-length_km": {}, "mapframe-length_mi": {}, "mapframe-area_km2": {}, "mapframe-area_mi2": {}, "mapframe-frame-coordinates": {} } } </templatedata>

See also