Template:Vector map

From OpenStreetMap Wiki
Jump to navigation Jump to search
[Edit] [Purge] Template-info.svg Template documentation

Embeds an interactive map powered by MapLibre GL JS, a vector tile renderer.

Compared to {{Slippymap}}, this template supports a more sophisticated user experience and additional layers. However, it requires a more advanced browser and graphics environment, and the map appears blank when printed out. Use this template when an article needs to communicate or demonstrate some detail that one of the featured (raster) tile layer cannot convey effectively. To avoid impacting page loading and scrolling performance, limit the number of embedded maps of any kind, vector or raster, on a single page.

Usage

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=americana}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=historic|date=1965-06-01}}

{{Vector map|layer=americana|commons=Kentucky Route 2354.map}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=carto}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=cyclosm}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=cycle-map}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=transport-map}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|layer=humanitarian}}

Parameters

Size

The following parameters determine the size of the map on screen:

|width =
Width of the map in pixels. |width = full fits available space. Defaults to 400 pixels.
|height =
Height of the map in pixels. Defaults to 400 pixels.

Camera

The following parameters determine the map camera (viewport):

|lat =
Initial center latitude. Defaults to 0 degrees (equator).
|lon =
Initial center longitude. Defaults to 0 degrees (prime meridian).
|zoom =
Initial vector zoom level. A vector zoom level is one less than a conventional raster zoom level seen in Leaflet-based websites such as openstreetmap.org or openhistoricalmap.org. May be a fractional number such as 10.5. Defaults to 11.
|bearing =
Initial bearing in degrees counterclockwise from north. Defaults to 0 degrees (due north).
|pitch =
Initial pitch in degrees away from the plane of the screen. Defaults to 0 degrees (lying flat on the screen).

Base map

The following parameters determine the contents of the base map:

|layer =
The map layer to display. Defaults to baremaps (as in Apache Baremaps, which develops a vector port of OpenStreetMap Carto called OpenStreetMap Vecto).
|date =
An ISO 8601-1 date by which to filter the data. Any map feature must have existed by this date to appear. Only supported when |layer = is set to an OpenHistoricalMap-based stylesheet; ignored otherwise.

Marker overlays

To mark locations on the map with pin-like markers, specify the latitude and longitude of each marker (n is a positive integer):

|markern-lat =
Latitude at which to place the marker.
|markern-lon =
Longitude at which to place the marker.

You can specify the first marker's latitude and longitude as |marker-lat = and |marker-lon =, omitting the number 1, or using the following deprecated parameters:

|mlat =
(Deprecated) Latitude at which to place the marker. Defaults to the value of |lat =.
|mlon =
(Deprecated) Longitude at which to place the marker. Defaults to the value of |lon =.

By default, a marker appears at the location specified by |lat = and |lon =. Set |marker = no to hide this marker.

GeoJSON overlays

To overlay arbitrary geographic data on the map, specify each source of GeoJSON data (n is a positive integer):

|commonsn =
The page name of a map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

If multiple page names are specified, the files are loaded as overlays in numeric order, with higher-numbered files drawn on top of lower-numbered files. Each file is downloaded separately from Wikimedia Commons. To minimize page load time, consider combining the files into one and uploading the combined file to Wikimedia Commons.

The first page name may be specified as |commons =.

Controls

The following parameters configure interactive controls on the map:

|navigation-position =
Corner in which the navigation controls appear. Defaults to the top-left corner. Set |navigation-position = none to hide the navigation controls.
|full-screen-position =
Corner in which the full screen control appears. Defaults to the top-left corner. Set |full-screen-position = none to hide the full screen control.
|attribution-position =
Corner in which the attribution control appears. Defaults to the bottom-right corner.

Layers

This template can display a number of vector stylesheets and raster tile layers. Raster tile layers are supported for backwards compatibility, but with a degraded user experience. These layers are defined in MediaWiki:Gadget-maps.js.

layer= Name Base data Tile format
americana OpenStreetMap Americana Lite[1] OpenStreetMap vector
baremaps Apache Baremaps OpenStreetMap vector
carto OpenStreetMap Carto OpenStreetMap raster
cycle-map OpenCycleMap OpenStreetMap raster
cyclosm CyclOSM OpenStreetMap raster
historic Historic OpenHistoricalMap vector
humanitarian Humanitarian OpenStreetMap raster
japanese scroll Japanese Scroll OpenHistoricalMap vector
railway Railway OpenHistoricalMap vector
transport-map Transport OpenStreetMap raster
woodblock Woodblock OpenHistoricalMap vector

Implementation

This template is powered by Module:Vector map, which simply inserts a placeholder <div> tag (optionally containing some placeholder <span> tags). MediaWiki:Gadget-maps.js, which is enabled by default for all users, detects this placeholder and responds by installing MapLibre GL JS, which populates the placeholder with an interactive map. MapLibre GL JS is loaded lazily from MediaWiki:Gadget-maplibre.js and MediaWiki:Gadget-maplibre.css, if and only if the page contains this placeholder, and only once even if there are multiple placeholders. MediaWiki:Gadget-mapbox-gl-rtl-text.js is loaded lazily if the map contains Arabic or Hebrew text. |layer = americana also causes MediaWiki:Gadget-maplibre-shield-generator.js to be loaded lazily.

Template data

Embeds an interactive map powered by MapLibre GL JS, a vector tile renderer.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Latitudelat

Initial center latitude. Defaults to 0 degrees (equator).

Default
0
Example
39.0799
Numbersuggested
Longitudelon

Initial center longitude. Defaults to 0 degrees (prime meridian).

Default
0
Example
-84.7037
Numbersuggested
Zoom levelzoom

Initial vector zoom level. A vector zoom level is one less than a conventional raster zoom level seen in Leaflet-based websites such as openstreetmap.org or openhistoricalmap.org. May be a fractional number such as 10.5. Defaults to 11.

Default
11
Example
10.5
Numberoptional
Bearingbearing

Initial bearing in degrees counterclockwise from north. Defaults to 0 degrees (due north).

Default
0
Example
45
Numberoptional
Pitchpitch

Initial pitch in degrees away from the plane of the screen. Defaults to 0 degrees (lying flat on the screen).

Default
0
Example
30
Numberoptional
Widthwidth

Width of the map in pixels. “full” fits available space. Defaults to 400 pixels.

Suggested values
full
Default
400
Example
300
Numberoptional
Heightheight

Height of the map in pixels. Defaults to 400 pixels.

Default
400
Example
300
Numberoptional
Layerlayer

The map layer to display. Defaults to “baremaps” (as in Apache Baremaps, which develops a vector port of OpenStreetMap Carto called OpenStreetMap Vecto).

Suggested values
americana baremaps carto cycle-map cyclosm historic humanitarian japanese scroll railway transport-map woodblock
Default
baremaps
Lineoptional
Datedate

An ISO 8601-1 date by which to filter the data. Any map feature must have existed by this date to appear. Only supported when “layer” is set to an OpenHistoricalMap-based stylesheet; ignored otherwise.

Example
2004-08-09
Dateoptional
Markermarker

By default, a marker appears at the location specified by “Latitude” and “Longitude”. Set to “no” to hide this marker.

Example
no
Booleanoptional
First marker latitudemarker-lat

Latitude at which to place the first marker. Defaults to the value of “Latitude”.

Example
39.0799
Numberoptional
First marker longitudemarker-lon

Longitude at which to place the first marker. Defaults to the value of “Longitude”.

Example
-84.7037
Numberoptional
Second marker latitudemarker2-lat

Latitude at which to place the second marker.

Example
39.0799
Numberoptional
Second marker longitudemarker2-lon

Longitude at which to place the second marker.

Example
-84.7037
Numberoptional
Third marker latitudemarker3-lat

Latitude at which to place the third marker.

Example
39.0799
Numberoptional
Third marker longitudemarker3-lon

Longitude at which to place the third marker.

Example
-84.7037
Numberoptional
Fourth marker latitudemarker4-lat

Latitude at which to place the fourth marker.

Example
39.0799
Numberoptional
Fourth marker longitudemarker4-lon

Longitude at which to place the fourth marker.

Example
-84.7037
Numberoptional
Fifth marker latitudemarker5-lat

Latitude at which to place the fifth marker.

Example
39.0799
Numberoptional
Fifth marker longitudemarker5-lon

Longitude at which to place the fifth marker.

Example
-84.7037
Numberoptional
Sixth marker latitudemarker6-lat

Latitude at which to place the sixth marker.

Example
39.0799
Numberoptional
Sixth marker longitudemarker6-lon

Longitude at which to place the sixth marker.

Example
-84.7037
Numberoptional
Seventh marker latitudemarker7-lat

Latitude at which to place the seventh marker.

Example
39.0799
Numberoptional
Seventh marker longitudemarker7-lon

Longitude at which to place the seventh marker.

Example
-84.7037
Numberoptional
Eighth marker latitudemarker8-lat

Latitude at which to place the eighth marker.

Example
39.0799
Numberoptional
Eighth marker longitudemarker8-lon

Longitude at which to place the eighth marker.

Example
-84.7037
Numberoptional
Ninth marker latitudemarker9-lat

Latitude at which to place the ninth marker.

Example
39.0799
Numberoptional
Ninth marker longitudemarker9-lon

Longitude at which to place the ninth marker.

Example
-84.7037
Numberoptional
Tenth marker latitudemarker10-lat

Latitude at which to place the tenth marker.

Example
39.0799
Numberoptional
Tenth marker longitudemarker10-lon

Longitude at which to place the tenth marker.

Example
-84.7037
Numberoptional
First Commons filecommons

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Second Commons filecommons2

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Third Commons filecommons3

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Fourth Commons filecommons4

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Fifth Commons filecommons5

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Sixth Commons filecommons6

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Seventh Commons filecommons7

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Eighth Commons filecommons8

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Ninth Commons filecommons9

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Tenth Commons filecommons10

The page name of a GeoJSON map data file on Wikimedia Commons to load as an overlay. Include the .map file extension but exclude the Data: namespace.

Example
Kentucky Route 2354.map
Lineoptional
Navigation control positionnavigation-position

Corner in which the navigation controls appear. Defaults to the top-left corner. Set to “none” to hide the navigation controls.

Suggested values
top-left top-right bottom-left bottom-right none
Default
top-left
Example
top-right
Lineoptional
Full screen control positionfull-screen-position

Corner in which the full screen control appears. Defaults to the top-left corner. Set to “none” to hide the full screen control.

Suggested values
top-left top-right bottom-left bottom-right none
Default
top-left
Example
top-right
Lineoptional
Attribution positionattribution-position

Corner in which the attribution control appears.

Suggested values
top-left top-right bottom-left bottom-right
Default
bottom-right
Example
bottom-left
Lineoptional
Marker latitudemlat

Latitude at which to place the marker. Defaults to the value of “Latitude”.

Example
39.0799
Numberdeprecated
Marker longitudemlon

Longitude at which to place the marker. Defaults to the value of “Longitude”.

Example
-84.7037
Numberdeprecated

Examples

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|width=300|height=300}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|width=300|height=300|marker1-lat=39.078598|marker1-lon=-84.707479}}

{{Vector map|zoom=13.5|lat=39.0799|lon=-84.7037|width=300|height=300|marker1-lat=39.078598|marker1-lon=-84.707479|layer=carto}}

See also

Notes and references

  1. Some features of OpenStreetMap Americana are not yet supported because they rely on runtime styling. Some point of interest icons are missing. Labels are only in the local language based on name=*, not the user's preferred language. Until these issues are resolved, visit the OpenStreetMap Americana demo site.