Template:Map
Embeds an interactive map on a page, provided the gadget MediaWiki:Gadget-maps.js is enabled. This gadget visualizes OpenStreetMap data using a variant of the OpenStreetMap Americana map style in a MapLibre GL JS map. On the AARoads wiki, this supersedes the Kartographer extension, and there is no implementation of that extension on this wiki.
Uses
This template is intended to show points as well as linear features on a map, including (but not limited to):
- Roads
- Rivers
- Subway or train lines
- Ship courses
- Flight paths
- Explorers journeys
and more... This template can also be used to display point features on a map, i.e. coordinates.
Parameters
For overall display
- width
- Width, in pixels, of the map frame.
full
fits available space. - height
- Height, in pixels, of the map frame.
- navigation-position
- Corner in which the navigation controls appear, or
none
to hide the navigation controls. - attribution-position
- Corner in which the attribution control appears.
- zoom
- Zoom level of the map, from
1
to19
(larger numbers zoom in further); default is automatically determined by the map, unless the only feature is a single point. - lat
- Optional - initial coordinate of the center latitude of the map.
- lon
- Optional - initial coordinate of the center longitude of the map.
- bearing
- Initial bearing in degrees counterclockwise from north.
- pitch
- Initial pitch in degrees away from the plane of the screen.
- plain
- If anything other than
yes
(which is default), shows a surrounding frame with a caption (without this parameter, text parameter will be ignored). - align
- Alignment with respect to the page if map is not
plain
:left
,center
, orright
; default isright
. - text
- Caption displayed if map is not
plain
.
- layer
- Vector style or raster tileset ID; default is
usrd
Vector options include:
- Americana-based:
- Americana (
americana
) - AARoads (
usrd
), which implements the legacy standards for static maps adopted by the English Wikipedia’s WikiProject U.S. Roads.
- Americana (
- OpenHistoricalMap
historic
japanese scroll
woodblock
Raster options inlcude:
- OpenStreetMap tiles:
- OpenStreetMap Carto (
carto
) - CyclOSM (
cyclosm
) - Humanitarian (
humanitarian
)
- OpenStreetMap Carto (
- date
- ISO 8601-1 date for OpenHistoricalMap layers.
For each feature
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 |commons2=
, the third feature |commons3=
, and so on. Markers are numbered independently from commons calls, so features defined in both marker2
and commons2
, for example, will both appear in the map.
- marker-lat
- Defines the latitude of a marker to be placed on the map. When
lat
andlong
are not defined, this defines the initial center of the map. Multiple markers are defined in the formmarkerx-lat
, wherex
is the marker's index - marker-lon
- Defines the longitude of a marker to be placed on the map. When
lat
andlong
are not defined, this defines the initial center of the map. Multiple markers are defined in the formmarkerx-lon
, wherex
is the marker's index - commons
- The map data page to be overlaid on the map. Page names should include the
.map
extension, and exclude theData:
namespace. Instructions for how to generate maps from OSM data can be found at AARoads:Creating a GeoJSON file from OpenStreetMap
Overwriting styling
The properties of a data layer can be overwritten within the template by defining parameters as shown below, where style
is replaced by any of these parameters:
- title
- description
- stroke-color
- stroke-width
- stroke-opacity
- fill
- fill-opacity
- stylex
- If a single value is put here, it will override all features in layer x with that value. Representing this parameter as a JSON object in the format
{"id1": "value1", "id2": "value2"}
identifies GeoJSON features in the layer where the key-value pairs in theproperties
object of the feature match the value to whatever theidy
key is in the template JSON object, and the property key to what's defined in the parameter style-keyx (which defaults totitle
) and then redefines that feature's property to the value in the JSON in the template (represented asvaluey
). For example, if there are features in layer 1 withname
values of "Thomas Vincent Ramos Highway", "Hummingbird Highway", and "Coastal Highway", and you wish for them to be red, green, and blue, respectively, then define the following parameters in the template:
stroke-color1={"Thomas Vincent Ramos Highway": "#f00", "Hummingbird Highway": "#0f0", "Coastal Highway": "#00f"}|stroke-color-key1=name
Note that if you only wish to affect one data layer, a suffix must be given
- style
- Overrides all features in the map not overwritten by a stylex parameter with this value. This can be represented as a single value or as a JSON object using the same method as the stylex parameters
Comparer
By defining an attribute within the frame with two values prefixed with COMP:
and separated by either,
, or ;
if the labels contain commas, or ###
if the labels contain semi-colons, the map will show a scrubber that divides the frame with value1
on the left and value2
on the right, with a slider to adjust the frames of each. All values not defined in this manner will be the same in both views.
Attributes that can be changed between views include commons
, marker
, layer
, and date
.
Example:
{{Map|zoom=10|commons=COMP:New Jersey Route 3.map, New Jersey Route 4.map}}
Multiple map switcher
This aspect cannot be implemented until the switcher gadget is imported |
An option for Template:Switcher-style switching of multiple mapframes, where specified parameters like zoom, or frame coordinates, or features are switched between different values. When using, ensure the number of values in each list are the same. If there are more values than switch labels, later ones will be ignored; if there are less, the last value will be repeated for all subsequent labels.
Instructions:
- Add parameter switch to specify labels for the different options: a list separated by either
,
, or;
if the labels contain commas, or###
if the labels contain semi-colons. Each label will be displayed with a prefix of "Show ".- Example:
|switch=zoomed out, zoomed mid, zoomed in
- Example:
- For each parameter that is to be switched, set its value to SWITCH: followed by a list of values to switch between, again separated by
,
or;
or###
- Example:
|zoom=SWITCH:4;9;14
- Parameters frame, plain, and text should not be switched
- Example:
- Make sure each list has the same number of entries. The position of value in a SWITCH: list corresponds to the same position in the list of labels set in
|switch=
.
Example:
{{Map|marker-lat=42.360278|marker-lon=-71.057778|text=Boston|zoom=SWITCH:4;9;14|switch=zoomed out, zoomed mid, zoomed in}}
Both this and the comparer can be used in the same template. Comparer entries are combined before switcher entries.
Example:
{{Map |marker-lat=SWITCH:38.973056, 38.189167; 44.310556, 43.66 |marker-lon=SWITCH:-76.501111, -76.432222; -69.779444, -70.255 |text=Capitals of US States |switch=capital of Maryland, capital of Maine}}
References
This template was originally based on a template on the OpenStreetMap Wiki.