Configuration

From Maps for MediaWiki

Maps works out of the box, with no configuration required.

You can configure Maps via the LocalSettings.php file in your wiki’s root directory. If you are not familiar with this file, please have a look at MediaWiki’s “LocalSettings.php” manual.

Since Maps 14.0.0, most settings can also be set on the wiki itself; see On-wiki configuration below.

Configuration Example

wfLoadExtension( 'Maps' );
$egMapsDefaultService = 'leaflet';
$egMapsMapWidth = 500;

On-wiki configuration

Available since Maps 14.0.0

Most Maps settings can also be configured on the MediaWiki:Maps page, making them editable by wiki administrators without server access. The page contains JSON and, like other site configuration, can only be edited by users with the editinterface and editsitejson rights, which, by default, means administrators and interface administrators. The page is validated when saved: an edit that does not match the expected structure is rejected with an error naming the invalid key. When the page is first created, it is preloaded with a small working example.

Settings are grouped by service and topic:

{
	"general": {
		"mapWidth": "100%",
		"mapHeight": "500px",
		"distanceUnit": "km"
	},
	"coordinates": {
		"notation": "float",
		"directional": false
	},
	"geocoding": {
		"service": "google"
	},
	"leaflet": {
		"defaultZoom": 5,
		"layerDefinitions": {
			"Historic 1904": {
				"url": "https://tiles.example.org/historic1904/{z}/{x}/{y}.png",
				"options": { "attribution": "Historic map tiles", "maxZoom": 18 }
			}
		}
	},
	"googleMaps": {
		"zoom": 5,
		"type": "satellite"
	}
}

The available groups and keys correspond to LocalSettings.php settings:

  • general: mapWidth, mapHeight, defaultTitle, defaultLabel, resizableByDefault, rezoomForKml, allowExternalKml, pagesWithMapsCategory, distanceUnits, distanceUnit, distanceDecimals
  • coordinates: availableNotations, notation, directional
  • geocoding: service (geonames, google or nominatim)
  • semanticMediaWiki: showTitle, hideNamespace, template, coordinateFormat, coordinateDirectional
  • leaflet: layerDefinitions, defaultLayers, defaultOverlays, availableLayers, availableOverlays, defaultZoom
  • googleMaps: zoom, type, types, controls, typeControlStyle, zoomControlStyle, autoInfoWindows, layers, showPoi, language

Values from the page are combined with those from LocalSettings.php, with the page taking precedence. Most settings are replaced wholesale. Only leaflet.layerDefinitions, leaflet.availableLayers and leaflet.availableOverlays are merged per name, so the page only needs to list the entries it changes. Changes take effect the next time a page with a map is parsed.

Secrets such as API keys, settings that run before a wiki page is read, the default mapping service ($egMapsDefaultService), and cache settings remain exclusive to LocalSettings.php. On-wiki configuration is enabled by default; to disable it entirely, set $egMapsEnableInWikiConfig = false;, and the page will never be read.

Supported Configuration

You can find a list of all configuration settings supported by the latest version of Maps in the “DefaultSettings.php” file.

If you are using an older version of Maps, you can view the configuration settings supported in that version by looking at the “DefaultSettings.php” file of your wiki. You can find it at extensions/Maps/DefaultSettings.php. If this file does not exist, look for Maps_Settings.php instead.