MediaWiki extension

From OpenStreetMap Wiki
(Redirected from MediaWiki plugin)
Jump to navigation Jump to search

The OpenStreetMap MediaWiki extensions allow our maps to be placed on a page of a wiki, on any installation of MediaWiki (https://mediawiki.org) where the extension has been installed. Two of the extensions below, were created for and installed on this wiki.

About MediaWiki extensions

MediaWiki extensions are bits of php logic which can optionally be dropped into a MediaWiki installation (not by any user, but by the server administrator), to give the wiki new capabilities. Various hooks are available. In this case we are probably most interested in extending the wiki syntax to support a new tag e.g. <map lat=... lon=... /> ...which would result in an OSM map appearing when you save the page. See Extending wiki markup

Installed extensions

(An overview over all installed extensions can be found here.)

Main article: Wiki:Maps#Slippy maps

Kartographer

Kartographer inserts a Leaflet map onto a wiki page. You can link text on the page to markers on the map. This extension was developed by the Wikimedia Foundation and is used on Wikivoyage and other Wikimedia wikis. The extension is modified in order to display featured tile layers. Previously, it had to be ruled out for this wiki because it could not display the standard tile layer of OpenStreetMap back then.[1]

Use

For an easy use of the extension, the template {{Slippymap}} was created. It provides an interface for displaying the map including a marker without knowing the specific syntax of the extension behind.

(Notice: Users should not use that syntax, because otherwise all pages need to be changed when the extension's syntax changed or it is replaced with a new extension. The former happened once the latter happened twice already and resulted in a thousands of page edits by bots. By using the template, only this has to be adjusted in the case of changes.)

If you need features which are not provided by Template:Slippymap, please extend it or create a new template, so we can avoid automated mass changes in the future.

Example

{{slippymap| lat= 51.47800 | lon = -0.00149 | width = 250 | height = 150 | zoom = 16 }}

Suggested map extensions

Maps

Maps is an up-to-date well maintained and feature rich MediaWiki extension for slippy maps in general. It is not installed on this wiki at the current time. It can display OpenStreetMap via OpenLayers. It has build in support for geocoding, displaying maps, displaying markers, adding pop-ups, and more. Maps allows extensive customization of maps, either per map, or via a general setting affecting all maps on the wiki.

Maps supports static maps also. Static maps are maps in the form of plain images, in contrast to dynamic maps, which reside in a JavaScript mapping API, and allow you to interact in various ways. Working with static maps has several advantages over dynamic maps, including the fact that users don't need to have a client that support JavaScript to view the map.

Starting with version 3.0, Maps requires to be installed with Composer. The last one does not work with our Chef management. An attempt to install it for the wiki failed in October 2018.[2]

Ideas for improvements

Local image caching

The simple image extension creates a straightforward reference to openstreetmap.org within an <IMG> tag. This is not ideal for several reasons:

A) It puts server load on OSM for other wiki's traffic (include CPU used to generate the image on the fly)
B) StaticMapLite goes down, the other wiki's articles are without a map.
C) StaticMapLite runs slowly, the maps load slowly on the other wiki's articles
D) Just as a general web design principle, the other wiki typically wants to be hosting all their referenced image resources.

The scale of these problems would depend on how widespread the use of this syntax would be (across how many wikis/articles) a solution which can be fairly simple, is local image caching.

For wikipedia's purposes, they can probably simply send tile requests through wikimedia's squid proxy cluster, which would handle the caching. Other people deploying this extension can do the same (set up their own squid proxy for the image URLs, and modify the extension to reference the proxy)

For other people using MediaWiki without squid proxies, we could provide some logic for local image caching within MediWiki. This would be logic for downloading the image file from the OSM server onto MediaWiki installation (just written to the filesystem?) and then always linking the <IMG> tags to local files. This downloading would happen on the first request (for a particular set of parameter values) and would not need to happen for subsequent requests, except after a timeout of some kind. A longer timeout length would make the caching more effective (less load on OSM, faster response for that wiki's users) but would make the map image potentially less current.

Harry Wood has had a go at building this (code so far is at Cached image MediaWiki Extension), but didn't get to test it yet because php's "fopen" command, which we need to use for programmatically performing the image download, seems to be disabled by default on many apache installations for security reasons.

Providing SVG source

Wikipedia is also interested in hosting 'source' data for images, and then allowing people to make changes to the SVG. This kind of idea might present some workflow problems. Obviously for raw mapping data the user should be referred to OSM. Should wikipedia serve up 'SVG' source files for rendered maps? This would enable contributors to make cosmetic tweaks to the renderings, but how does it fit with bringing in updates from OSM?

MediaWiki's thumbnail facility

MediaWiki supports various nifty bits of syntax for working with images, in particular it allows an image to be thumbnailed on the article page (show a rescaled small version linking to the full size version) just by adding something like 200px into the [[Image]] wiki text. Other options include frames and captions and left/right/center commands.

With the simple image extension, none of these tricks are available. The image appears full size. However this doesn't really matter because, the size of the map image would be dictated by the width/height parameters chosen, and in theory rescaling should never be particularly desireable, since the detail level and text size should be optimised within our rendering logic, to best match the particular zoom level.

Other questions though: Would it be nice to have something similar to 'image pages'? That might tie in well with the idea of having associated SVG resources. What about matching other features of the [[Image]] syntax, such as frames and captions. Or is all that unnecessary complication?

These considerations are largely meaningless with respect to the slippy map extension.

WikiMiniAtlas

User:Dschwen has already gone to considerable effort to develop something called WikiMiniAtlas for wikipedia, and it is in place already. This is not embedding maps within wiki articles, but providing them as a dropdown feature at the top of the page, for articles which have been geotagged. As such, it's not the same idea as those discussed on this page, and perhaps it doesn't particularly conflict at all. i.e. we'd like both.

We should definitely work with the developers to get our map data represented on there somehow (if not our maps full stop) See also Collaboration with Wikipedia

OpenStreetMap data is being used in the WikiMiniAtlas as of spring 2012.

Previously installed extensions

Multiple map extensions have been installed in this wiki. They were removed due to technical incompatibilities.

Simple image MediaWiki Extension

The extension displayed static maps as images and required a provider for static map images. Previous providers stopped their services and nobody was interested in running such a service specifically for this wiki.[3]

Slippy Map MediaWiki Extension

An extension whose development has been discontinued. It used to be installed in all OSM(F) wikis.

MultiMaps

This extension replaced the Slippy Map MediaWiki Extension in Summer 2020[4][5] and the SimpleMap Extension in May 2021[6].

It was chosen as a replacement for Slippy Map MediaWiki Extension, after experiencing problems with  Composer (software) when trying to install Maps extension. It is very basic, allowing the display of maps with a Leaflet frame only. The option to choose between tile sources was added specifically for this wiki[7], but since the code is hosted at Wikimedia, the option is available for all MediaWiki wikis. Following this code addition, no significant updates were made so the extension did not work with MediaWiki 1.39. It was replaced by Kartographer extension in January 2023.[8]

See Also

References