ES:Extensión MediaWiki de mapa deslizante

From OpenStreetMap Wiki
Jump to navigation Jump to search

This page describes a Slippy Map MediaWiki extension. See MediaWiki extension for details of other ideas / enhancements we could develop. This extension embeds an OpenLayers slippy map into the contents of the wiki page, for example:

Slippy map MediaWiki extension-small.PNG

Wiki users can add a 'slippymap' tag into the page wiki-text. In this they can specify parameters 'lat', 'lon', 'z' (zoom level), 'w' (width in pixels), 'h' (height in pixels), and 'layer' (mapnik, transport, or cycle)

The extension spits out the javascript which launches OpenLayers within a sized DIV


The extension allows anyone to embed a slippy map on a page with following syntax in the wikitext:

<slippymap lat="51.485" lon="-0.15" z="15" w="450" h="300" format="jpeg" layer="mapnik"/> 

To find the suitable lat/lon values, open a new browser window, look at the front page map and use the 'permalink' feature in the bottom right.

Note that the extension installed here also supports an old format: <slippymap>lat=51.485|lon=-0.15|z=11|w=450|h=330|layer=osmarender</slippymap>, but we should edit all the wiki pages to switch over to the new format.

Download & Installation

If you're running your own mediawiki, you can set it up to support <slippymap> tags by installing the extension as follows:

include("extensions/slippymap/SlippyMap.php"); //openstreetmap extension
  • Try it out!

MediaWiki Versions

Harry Wood originally created this to run on a really old v1.4 MediaWiki installation. The newer version probably isn't so backward compatible though.

Dependency note

This introduces a dependency between your wiki and the various openstreetmap tile servers. If openstreetmap ceases to provide images under these URLs, for whatever reason, then your wiki will still function, but it will show image errors.

We are offering no guarantees about the long-term continuation of this (or indeed any) openstreetmap service. Equally the extension code may be re-written, and you should aim to use the latest code available here. e.g. for security fixes.

There are a number of limitations and things which could be enhanced. The MediaWiki extension page has lots of ideas for this.

Known issues / ideas

  • Can't embed two different slippy maps on the same wiki page. This is because all the javascript variable names and the 'id=map' document object cease to be unique. Fixable with a bit of hacking.
  • 'Data from OpenStreetMap' overlayed text should be vertically positioned slightly lower
    • Have you looked at the possibility of overriding the attribution control to display what you want? It can be styled with CSS. Bobkare 14:50, 27 February 2008 (UTC)
  • It snaps to 0/0 lat/lon when you do something with mouse. Can't work out what exactly.
I think I know when this happens: click first on [wiki], close window and drag the map. --Willem1 19:22, 15 May 2009 (UTC)

Enhancement ideas

Add ideas here, or on the talk page

  • Support adding a marker or multiple pins.
    • Currently disabled while we decide best wiki syntax
    • Ideally follow the same g-maps extension syntax
    • Could provide a param option to disallow slippiness (useful?)
  • Display localized tiles from the Wikimedia Toolserver
  • Ability to display other slippy map tiles, e.g. from ITO Map

Who's working on it

  • Harry Wood
  • Firefishy
  • JeLuF and raimond spekking did some stuff over at
  • Feel free to join in

The extension code

The code has been re-homed in several confusing ways over the years. On this wiki page -> OSM's svn -> Mediawiki's SVN -> wikimedia gerrit. These days this wiki is pulling from:

Also See