Wikipedia:Technik/Skin/Gadgets/OpenStreetMap/wiwosm

This is a gadget code to update MediaWiki:OSM.js (legacy code).

Functionality

Bearbeiten

All traditional functionality will be supported (legacy).

Added functionality:

  • The configuration may be sent by mw.hook() calls.
  • Mobile interface is supported.
  • Element identification is independent of unchangeable selectors.
  • Multiple coordinates are possible.
  • Position of map insertion can be chosen individually.

Configuration

Bearbeiten

One or multiple times the following request may be issued, before gadget loading was started:

mw.hook( "wiwosm.config" ).fire( options );
  • options is an object with components as described below.
  • Some or all components may be set.
  • Multiple calls will redefine those components.
  • Invalid assignments will be ignored silently.
  • Components:
$coordinate
jQuery set of one or more coordinate elements.
A coordinate element is defining the URL to create a map.
Every coordinate element is supposed to contain one more <a> elements.
The first URL with string geohack but no extraterrestric indication will specify the related URL.
Only elements with assigned URL are considered as coordinate element.
Default (legacy): First element in page matching #coordinate selector.
$container
jQuery set of one or more container elements.
A container element is the place where to show the map.
Multiple container elements will be assigned to coordinate elements, respectively.
Coordinate elements not assigned to a particular container element will use the first container element.
Default (legacy): Top of page
$widget
jQuery set of one or more widget elements.
A widget element will be appended to each coordinate element.
A single widget element might be provided as pattern for all coordinate elements, or a set might be given with individual widgets per coordinate.
Coordinate elements not assigned to a particular widget element will use the first widget element.
Default (legacy): composed of
$toggle
jQuery set of one or more toggle elements.
A toggle element is supposed to be part of related widget element.
A toggle element is an element which will receive toggle clicks to show or hide the map.
If a set of widget elements is provided, the set of toggle elements needs to be related respectively.
Default (legacy):
height
Initial minimum height of the map, as number of pixels.
Default (legacy): 350
lang
Language code of map contents.
One or both of:
  • string – default code for all maps
  • Array of either string or false – codes will be assigned to coordinate elements, respectively. Missing or false elements will use fallbacks.
Defaults:

The legacy approach is storing strings into system configuration.

  • Actually, mw.config.get() is supposed to contain MediaWiki system configuration only.
  • The following strings may be set:
osm_proj_map_map
HTML code to specify a toggle.
osm_proj_map_prefix
HTML code to prefix a toggle.
osm_proj_map_postfix
HTML code to postfix a toggle.
osm_proj_lang
Language code of map contents.