0 Stimmen

Map Macro

Zuletzt geändert von xwikiadmin am 2024/01/25 22:03

Description

Displays an interactive geographical map.

This macro does not supports inline mode.

You will need connectivity back and forth from the wiki to either OpenStreetMap or Google Maps servers for the macro to properly work. This might not be the case for a intranet in a corporate environment for example. 

Content

The content is optional and is used for displaying information in a popup activated on click. With Leaflet, if there is no content a click leads to the OpenStreetMap routing service.

Parameters

NameMandatoryValuesDefaultDescription
locationYes*-Address of a place
widthNo[0-9]+px or % 500pxThe width in pixels or in percent the map container will take
heightNo[0-9]+px or %400pxThe height in pixels or in percent the map container will take
zoomNo[0-9]+15 (which is about the size of a block of houses)The initial zoom the map will be focused at. Please refer to your provider API reference for intelligible values.
errorsNoshow / hideshowDisplay a popup with the returned status code when it is anything other than "OK"
locationTypeNoaddress/latlngaddressSince 1.2.3 Specify the type of location, possible values : address (default) or latlng ( in this case the location should be a geographic coordinate like : 47.156427, 27.576387)
tilesNoOSM tile serverURL scheme of the tile provider. Example: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png (default). See also: OpenStreetMap tile servers. The tile provider can be set either from the map macro administration page (see below) or at the macro level.

Administration

Choose the map library (either Leaflet (default) or Google Maps) and the tile server directly from the map macro administration section. To use the Google Maps JavaScript API or the Mapbox tile server, you must register your app project on the Google API Console or on the Mapbox console and get a Google API key or a Mapbox token, which you can add to your app.

Examples

Map with default OpenStreetMap tiles

Code:

{{map location="35 rue Beaubourg, 75003 Paris, France" /}}

Result:

Map using geographic coordinates and percent width

Code:

{{map location="47.156427, 27.576387" locationType="latlng" width="50%" /}}

Result:

Map with information popup

Code:

{{map location="Rue des Thermopyles, 75014 Paris" width="400px" height="300px"}}
A beautiful street in Paris
{{/map}}

Result:

A beautiful street in Paris

Map with custom tiles

Code:

{{map location="35 rue Beaubourg, 75003 Paris" tiles="http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg" /}}

Result:

Map with Google Maps tiles

In order to use the Google Maps tiles, head to the map macro administration section as explained above, and select "Google Maps" library. In that case, you don't need to fill in any tile server as it is automatically set to the Google Maps one.

Google Maps Events

If you use the Google Maps library, the events listed below are available.

NameDescription
GMAPS:OKIndicates that no errors occurred; the address was successfully parsed and at least one geocode was returned
GMAPS:ZERO_RESULTSIndicates that the geocode was successful but returned no results. This may occur if the geocoder was passed a non-existent address.
GMAPS:OVER_QUERY_LIMITIndicates that you are over your quota.
GMAPS:REQUEST_DENIEDIndicates that your request was denied.
GMAPS:INVALID_REQUESTGenerally indicates that the query (address, components or latlng) is missing.
GMAPS:UNKNOWN_ERRORIndicates that the request could not be processed due to a server error. The request may succeed if you try again.
Powered by MakerspaceBonn e.V.