Template:Map compare

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

Embeds an interactive comparison between two maps based on {{Vector map}}. Drag the scrubber left and right to reveal more of one map or the other.

Usage

{{Map compare|lat=39.10599|lon=-84.5291|zoom=14|marker=no|layer=carto|layer2=baremaps}}

{{Map compare|lat=39.27541|lon=-84.28405|zoom=14|marker=no|layer=historic|date=1992-08-01|date2=2024-12-25}}

Parameters

This template supports all of the parameters of {{Vector map}}, with the addition of:

|layer2 =
The map layer to display on the right-hand side of the comparison. Defaults to the value of |layer =, which is always used on the left-hand side.
|date2 =
An ISO 8601-1 date by which to filter the data on the right-hand side of the comparison. Defaults to the value of |date =, which is always used on the left-hand side.

Additionally, |width = defaults to full (occupying the available space) instead of 400 pixels.

Implementation

This template simply inserts a placeholder <div> tag containing two transclusions of {{Vector map}}. MediaWiki:Gadget-maps.js, which is enabled by default for all users, detects this placeholder and responds by installing MapLibre GL Compare, which populates the placeholder with an interactive map copmarison. MapLibre GL Compare is loaded lazily from MediaWiki:Gadget-maplibre-gl-compare.js and MediaWiki:Gadget-maplibre-gl-compare.css, if and only if the page contains this placeholder, and only once even if there are multiple placeholders.

Template data

Embeds an interactive comparison between two vector maps. Drag the scrubber left and right to reveal more of one map or the other.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Latitudelat

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

Default
0
Example
39.0799
Linesuggested
Longitudelon

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

Default
0
Example
-84.7037
Linesuggested
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 “full”.

Suggested values
full
Default
full
Example
800
Lineoptional
Heightheight

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

Default
400
Example
300
Lineoptional
Left layerlayer

The map layer to display on the left-hand side of the comparison. 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
Right layerlayer2

The map layer to display on the right-hand side of the comparison. Defaults to the value of “layer”, which is always used on the left-hand side.

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

An ISO 8601-1 date by which to filter the data on the left-hand side of the comparison. 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
Right datedate2

An ISO 8601-1 date by which to filter the data on the right-hand side of the comparison. Defaults to the value of “date”, which is always used on the left-hand side.

Example
2004-08-09
Dateoptional
Commonscommons

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
Markermarker

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

Example
no
Booleanoptional
Marker latitudemlat

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

Example
39.0799
Numberoptional
Marker longitudemlon

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

Example
-84.7037
Numberoptional
Left attribution positionattribution-position

Corner of the left-hand side’s map in which the attribution control appears.

Suggested values
top-left top-right bottom-left bottom-right
Default
bottom-left
Example
top-left
Lineoptional
Right attribution positionattribution-position2

Corner of the right-hand side’s map in which the attribution control appears.

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

See also