Template:Mapframe/doc: Difference between revisions

Template page
mNo edit summary
 
m (1 revision imported from wikivoyage:Template:Mapframe/doc)
 
(No difference)

Latest revision as of 22:23, 21 May 2024

Template:Ombox

Function

This template acts as a frame for an external map. Javascript is used to replace "mapdiv" with an iframe. See Wikivoyage:How to use dynamic maps and Wikivoyage:Dynamic maps Expedition for more information.

Usage

<syntaxhighlight lang="wikitext" inline><mapframe align="right" height="420" image="" latitude="1" longitude="2" show="Template:Maplayers" title="" url="" width="420"></mapframe></syntaxhighlight>

Parameters

|1 latitude of the map's centre, valid range: -90.0 to 90.0
|2 longitude of the map's centre, valid range: -180.0 to 180.0
|zoom= zoom level, default=14, valid range: 0 to 18 or auto (0=Earth, 18=city block, auto=showing all markers)
|height= height of map frame in pixels, default is 420 and it should be at least 370 to provide enough space for the layers menu to expand
|width= width of map frame in pixels, default is 420
|staticmap= static map image, a normal png or svg file
|align= alignment of map frame, default is right (other values are "left" and "center")
|name= name of the location as you want it to appear in the caption; the default display is the article title with parent page and disambiguation removed. For an example of this parameter's usage, see Amsterdam/Binnenstad.
|layer= see Wikivoyage:How to use dynamic maps#Mapframe

If the coordinates are not given, they and the zoom will be deduced from the markers and the possible mapshapes etc. to be shown. This works well in some cases, but can give a strange result in others (such as if there is an airport far from a city to be shown).

Examples

<syntaxhighlight lang="wikitext" style="white-space: pre-wrap;"> <mapframe align="right" height="420" image="" latitude="51.47766" longitude="0.00115" show="Template:Maplayers" text="Map of doc" title="" url="" width="420"></mapframe></syntaxhighlight> <syntaxhighlight lang="wikitext" style="white-space: pre-wrap;"> <mapframe align="right" height="420" image="" show="Template:Maplayers" text="Map of doc" title="" url="" width="420"></mapframe> (lat/long is not required)</syntaxhighlight> <syntaxhighlight lang="wikitext" style="white-space: pre-wrap;"> <mapframe align="right" height="400" image="" latitude="51.47766" longitude="0.00115" show="Template:Maplayers" text="<div class="magnify" title="Enlarge map">Template:Maplink</div>Map of doc" title="" url="" width="400" zoom="14"></mapframe></syntaxhighlight> <syntaxhighlight lang="wikitext" style="white-space: pre-wrap;"> <mapframe align="right" height="400" image="" latitude="51.47766" longitude="0.00115" show="Template:Maplayers" text="<div class="magnify" title="Enlarge map">Template:Maplink</div>Map of doc<div class="wv-staticMap">Map of doc</div>" title="" url="" width="400" zoom="14"></mapframe></syntaxhighlight> <syntaxhighlight lang="wikitext" style="white-space: pre-wrap;"> <mapframe align="center" height="400" image="" latitude="51.47766" longitude="0.00115" show="Template:Maplayers" text="<div class="magnify" title="Enlarge map">Template:Maplink</div>the Binnenstad" title="" url="" width="400" zoom="14"></mapframe></syntaxhighlight>

Associated template

  • {{mapshape}} – used to create a mask, shape or line using data from the OpenStreetMap database; useful for city or region borders, or for showing routes.
  • {{mapmask}} – used to create a mask using manually entered latitude/longitude pairs; useful for drawing city or region borders that aren't available from OpenStreetMap.
  • {{maplayers}} – list of maplayer names, to facilitate adding a custom layer.

Code

  • Module:Map used to create <mapframe> tag with all of the parameters

Template Data

This template acts as a frame for an external map. Javascript is used to replace "mapdiv" with an iframe. See [[Wikivoyage:How to use dynamic maps]] and [[Wikivoyage:Dynamic maps Expedition]] for more information.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Latitude1

Latitude of the map's centre, -90 to 90

Example
51.47766
Numbersuggested
Longitude2

Longitude of the map's centre, -180 to 180

Example
0.00115
Numbersuggested
Zoom levelzoom

Zoom level from 0-18 (0=Earth, 18=city block, auto=fit all markers)

Example
14
Numbersuggested
Widthwidth

Width of map frame

Default
420
Example
400
Numberoptional
Heightheight

Height of map frame

Default
420
Example
400
Numberoptional
Namename

Name of the location as you want it to appear in the caption

Default
Article title
Example
the Binnenstad
Unknownoptional
Alignmentalign

Alignment of the map frame, left/right/center

Suggested values
left right center
Default
right
Example
center
Stringoptional
Layerlayer

List of layers to show, see [[Wikivoyage:How to use dynamic maps#Mapframe]]

Example
MLSCG
Stringoptional
Static map imagestaticmap

A PNG or SVG file to serve as the static map image

Example
map.png
Fileoptional