Template:Vector map
Note to editors: Please don't categorize this template by editing it directly. Instead, place the category in its documentation page, in its "includeonly" section.
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.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Latitude | lat | Initial center latitude. Defaults to 0 degrees (equator).
| Number | suggested |
Longitude | lon | Initial center longitude. Defaults to 0 degrees (prime meridian).
| Number | suggested |
Zoom level | 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.
| Number | optional |
Bearing | bearing | Initial bearing in degrees counterclockwise from north. Defaults to 0 degrees (due north).
| Number | optional |
Pitch | pitch | Initial pitch in degrees away from the plane of the screen. Defaults to 0 degrees (lying flat on the screen).
| Number | optional |
Width | width | Width of the map in pixels. “full” fits available space. Defaults to 400 pixels.
| Number | optional |
Height | height | Height of the map in pixels. Defaults to 400 pixels.
| Number | optional |
Layer | layer | The map layer to display. Defaults to “baremaps” (as in Apache Baremaps, which develops a vector port of OpenStreetMap Carto called OpenStreetMap Vecto).
| Line | optional |
Date | 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.
| Date | optional |
Marker | marker | By default, a marker appears at the location specified by “Latitude” and “Longitude”. Set to “no” to hide this marker.
| Boolean | optional |
First marker latitude | marker-lat | Latitude at which to place the first marker. Defaults to the value of “Latitude”.
| Number | optional |
First marker longitude | marker-lon | Longitude at which to place the first marker. Defaults to the value of “Longitude”.
| Number | optional |
Second marker latitude | marker2-lat | Latitude at which to place the second marker.
| Number | optional |
Second marker longitude | marker2-lon | Longitude at which to place the second marker.
| Number | optional |
Third marker latitude | marker3-lat | Latitude at which to place the third marker.
| Number | optional |
Third marker longitude | marker3-lon | Longitude at which to place the third marker.
| Number | optional |
Fourth marker latitude | marker4-lat | Latitude at which to place the fourth marker.
| Number | optional |
Fourth marker longitude | marker4-lon | Longitude at which to place the fourth marker.
| Number | optional |
Fifth marker latitude | marker5-lat | Latitude at which to place the fifth marker.
| Number | optional |
Fifth marker longitude | marker5-lon | Longitude at which to place the fifth marker.
| Number | optional |
Sixth marker latitude | marker6-lat | Latitude at which to place the sixth marker.
| Number | optional |
Sixth marker longitude | marker6-lon | Longitude at which to place the sixth marker.
| Number | optional |
Seventh marker latitude | marker7-lat | Latitude at which to place the seventh marker.
| Number | optional |
Seventh marker longitude | marker7-lon | Longitude at which to place the seventh marker.
| Number | optional |
Eighth marker latitude | marker8-lat | Latitude at which to place the eighth marker.
| Number | optional |
Eighth marker longitude | marker8-lon | Longitude at which to place the eighth marker.
| Number | optional |
Ninth marker latitude | marker9-lat | Latitude at which to place the ninth marker.
| Number | optional |
Ninth marker longitude | marker9-lon | Longitude at which to place the ninth marker.
| Number | optional |
Tenth marker latitude | marker10-lat | Latitude at which to place the tenth marker.
| Number | optional |
Tenth marker longitude | marker10-lon | Longitude at which to place the tenth marker.
| Number | optional |
First Commons file | commons | 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.
| Line | optional |
Second Commons file | commons2 | 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.
| Line | optional |
Third Commons file | commons3 | 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.
| Line | optional |
Fourth Commons file | commons4 | 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.
| Line | optional |
Fifth Commons file | commons5 | 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.
| Line | optional |
Sixth Commons file | commons6 | 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.
| Line | optional |
Seventh Commons file | commons7 | 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.
| Line | optional |
Eighth Commons file | commons8 | 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.
| Line | optional |
Ninth Commons file | commons9 | 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.
| Line | optional |
Tenth Commons file | commons10 | 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.
| Line | optional |
Navigation control position | navigation-position | Corner in which the navigation controls appear. Defaults to the top-left corner. Set to “none” to hide the navigation controls.
| Line | optional |
Full screen control position | full-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.
| Line | optional |
Attribution position | attribution-position | Corner in which the attribution control appears.
| Line | optional |
Marker latitude | mlat | Latitude at which to place the marker. Defaults to the value of “Latitude”.
| Number | deprecated |
Marker longitude | mlon | Longitude at which to place the marker. Defaults to the value of “Longitude”.
| Number | deprecated |
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
- Module:CarouselMap – inserts this template based on a rotating configuration
- {{Map compare}} – interactive comparison between two vector maps
- {{Slippymap}} – raster map powered by Kartographer and Leaflet
Notes and references
- ↑ 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.