Extension:Maps/Displaying maps

From semantic-mediawiki.org
< Extension "Maps"
Extension "Maps"Extension:Maps/Displaying maps
Maps extension
Overview
Installation and Configuration
Usage
Displaying maps
Customizing maps
Displaying GeoJSON
Geocoding
Converting coordinates
SMW integration
Storing coordinates
Aggregating onto a map
On this page

The #display_map parser function[edit]

Displaying maps is done with the #display_map parser function.

{{#display_map:Brandenburg Gate, Berlin, Germany}}

You can display multiple locations by separating them with semicolons. And it is possible to use coordinates instead of location names.

{{#display_map:Berlin; Brussel; 40° 42' 46.02" N, 74° 0' 21.39" W}}

The maps can be customized with a good number of parameters. Most notably the service parameter, which allows you to specify the mapping service to use.

{{#display_map:Berlin|width=400|height=300|service=leaflet}}

The available parameters depend on the mapping service you pick.

Is is recommended to prefer leaflet mapping service 1 over the openlayers mapping service since only an old version of the latter is provided. This information is current as of August 26, 2018 for Maps 5.x and later.

Displaying data[edit]

The #display_map parser function supports a number of parameters that allow you to display markers and shapes on the map.

Markers[edit]

Via the locations parameter you can have the map display markers. This is the main parameter of #display_map and is normally not named explicitly. These can be addresses or coordinates (and you can mix the two).

Example:

{{#display_map:locations=Berlin; Brussel; 40° 42' 46.02" N, 74° 0' 21.39" W}}

You can customize the markers per location. (Map wide customization is also possible via dedicated parameters.) The syntax is:

Location~Popup title~Popup text~File:CustomIcon~Group~Inline label~File:VisitedIcon
  • Location: the location where to display the marker. This can be a set of coordinates or an address
  • Popup title and Popup text: optional content for a popup shown when the marker is clicked. No popup is shown if both are empty
  • File:CustomIcon: optional name of an image to display instead of the default marker
  • Group:
  • Inline label: optional label shown next to the marker. Currently only shown when using Google Maps
  • File:VisitedIcon: optional name of an image to display as marker when the marker is clicked

Example:

{{#display_map:
  Berlin~The city Berlin~Berlin is a really nice city and there is plenty of Club Mate~Blue marker.png;
  Brussel~The city Brussel~Burssel is meh!~Green marker.png
}}
Loading map...

Alternative syntax[edit]

When you have many customized markers, using the #display_map parser function can get unwieldy. For this reason you can also use the <display_map> tag. It has all the same parameters as the parser function, the only difference is the syntax. Each location goes own its own line and they do not need to be separated with a semicolon.

Example:

<display_map height="150px" scrollwheelzoom="off" service="google">
  Gent, Belgie~The city Ghent~Ghent is awesome~ ~ ~Ghent
  Brussel~The city Brussel~The capital of Belgium~ ~ ~Brussels
  Antwerp~The city Antwerp~ ~ ~ ~Antwerp
</display_map>
Loading map...

GeoJSON[edit]

As of version 5.6, Maps supports display of GeoJSON via the geojson parameter. See Displaying GeoJSON.

Lines[edit]

Via the lines parameter you can display lines on the map. Each line has at least two locations. As with markers you can specify a popup title and text. You can also specify the looks of the line. The syntax is:

First address:Second address:Optional third address:etc
~Popup title~Popup text~Line color~Line opacity~Line thickness

Example:

{{#display_map:lines=
  Berlin:Brussels:London;
  Amsterdam:Paris~Amsterdam to Paris line~I am a text~green~0.42~10
}}
Loading map...

Polygons[edit]

Via the polygons parameter you can display polygons on the map. Each polygons has at least two locations. As with markers you can specify a popup title and text. You can also specify the looks of the polygon. The syntax is:

First address:Second address:Optional third address
~Popup title~Popup text~Border color~Border opacity~Border thickness~Fill color~Fill opacity
~Show only on hover

Example:

{{#display_map:polygons=
  Berlin:Brussels:London;
  Amsterdam:Paris:Frankfurt~I am a title~And I am a description~green~0.7~10~blue~0.5
}}
Loading map...

Circles[edit]

Via the circles parameter you can display circles on the map. Each circles has a center and a diameter. You can specify the popup title and text and the looks of the circle. The syntax is:

Address of the center:Diameter~Popup title~Popup text~Border color~Border opacity~Border thickness~Fill color~Fill opacity

Example:

{{#display_map:circles=
  Amsterdam:500;
  Amsterdam:100~I am a title~And I am a description~green~0.7~10~blue~0.5
| zoom=14
}}
Loading map...

Rectangles[edit]

Via the rectangles parameter you can display rectangles on the map. Each rectangle has a North East location and a South West location. You can specify the popup title and text and the looks of the rectangle. The syntax is:

North East location:South West location
~Popup title~Popup text~Border color~Border opacity~Border thickness~Fill color~Fill opacity

Example:

{{#display_map:rectangles=
  Berlin:Brussels;
  Amsterdam:London~I am a title~And I am a description~green~0.7~10~blue~0.5
}}
Loading map...

References

  1. ^  Maps: GitHub issue comment gh:m:165:415969303