Difference between revisions of "Template:Mapshape/doc"
Template>Mx. Granger (→OSM wikidata tags: fixing link) |
(No difference)
|
Revision as of 17:44, 6 November 2019
This is a documentation subpage for Template:Mapshape. It contains usage information, categories and other content that is not part of the original template page. |
Documentation
This template overlays a mask (shade everything outside of a boundary), shape or line on a dynamic map. The coordinates for the overlay are pulled from the OpenStreetMap database and require that the OpenStreetMap record is linked to a Wikidata record - in many cases the "wikidata" field may need to be added to OpenStreetMap before this template can be used. For example, the Wikidata item for Alaska is Q797 and the OpenStreetMap record for Alaska (http://www.openstreetmap.org/relation/1116270) has a Wikidata ID, so that Wikidata ID may be used with this template. More than one ID may be specified separated by a comma.
To add a Wikidata ID to an OpenStreetMap record that does not contain one already, visit https://www.openstreetmap.org/ and add a Wikidata tag with the Q value. After updating OpenStreetMap it may take 2-3 days before the data becomes available for use by dynamic maps.
See mw:Help:Extension:Kartographer#External data for additional detail, or #OSM wikidata tags.
Parameters
- wikidata: (Optional) The Wikidata ID to use for the mask. If no value is specified then the default Wikidata ID for the page is used. Multiple IDs may be used if they are separated by commas.
- type: (Optional) The type of overlay to add. The default value is "geomask". Valid values are:
- "geomask" - shade everything outside of a boundary
- "geoshape" - shade everything inside of a boundary
- "geoline" - render a line
- "page" - use wikicommons GeoJSON map referenced by the parameter "wikicommons". For example, see e.g. Madrid.
- group: (Optional) Define a group to which the overlay should be added. This parameter should only be necessary when multiple dynamic maps are used on a page; in such cases, the {{mapframe}} template's "show" parameter should match the "group" parameter for its corresponding shape (see example below).
- fill: (Optional) An alternate color to use for the shape. Color must a valid web color, for example
#ff0000
for red. - opacity: (Optional) The amount of opacity for the area shaded by the mask or shape. Must be specified as a number between 0 and 1, where 0 means "completely transparent" and 1 means "completely opaque".
- stroke: (Optional) An alternate color to use for a line or the outline of a shape. Color must a valid web color, for example
#ff0000
for red. - stroke-width: (Optional) The width of a line or the outline of a shape. Must be specified as a number. Default is 1.
- stroke-opacity: (Optional) The level of opacity for a line. Must be specified as a number between 0 and 1, where 0 means "completely transparent" and 1 means "completely opaque". Default is 1.
- title: (Optional) Title to be shown when the mapshap is clicked (can contain a reference too, for example).
Example
Map mask using default values:
{{Mapframe|52.16|-112.15|zoom=3}} {{mapshape}}
Map shape using default Wikidata ID:
{{Mapframe|52.16|-112.15|zoom=3}} {{mapshape|type=geoshape}}
Multiple maps identified using "group" and "show" parameters:
{{Mapframe|52.16|-112.15|zoom=3|show=map1}} {{mapshape|wikidata=Q797|type=geoshape|group=map1}} {{Mapframe|34.006|-118.401|zoom=13|show=map3}} {{mapshape|wikidata=Q493378|group=map3}}
TemplateData
This template overlays a mask (shade everything outside of a boundary), shape or line on a dynamic map.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Wikidata link | wikidata | Wikidata QID corresponding to the OpenStreetMap record to use
| Number | optional |
Shape type | type | Valid values are 'geomask' (shade everything outside of a boundary), 'geoshape' (shade everything inside of a boundary) and 'geoline' (render a line)
| String | optional |
Group | group | Define a group to which the overlay should be added.
| String | optional |
OSM wikidata tags
To display e.g. mapshape of a metro line, as written above, the OSM relation and wikidata article need to be linked. Sometimes the situation is simple - for example, Q1292805 is linked to OSM relation ID 7772996, and also the other way around in OSM (see the wikidata tag there).
Many times, the wikidata may only reference a so-called Super-Relation. The template cannot currently handle this, as (author's educated guess) no ways are part of the relation directly. However it can be helped. For example, Q99691 links to OSM (super-)relation 58767, which already contains the link to the right wikidata. The relation consists of members relations 2669205 and 2669206 (both ways of the metro line). By adding tag wikidata=Q99691 to these child relations, no harm is done to OSM folks - and the Mapshape template will start work afterwards.
Editing tutorial
You may be in luck and the OSM data is already tagged. Use e.g. overpass-turbo and zoom to the city you want. Then enter the following query (replace WIKIDATA_ID with either of the above):
[out:json][timeout:25]; // gather results ( relation["wikidata"="WIKIDATA_ID"]({{bbox}}); ); // print results out body; >; out skel qt;
- If the individual line relation was found, take the relation number, enter it into wikidata and you are done. Continue with the rest of the transport lines.
- Otherwise, we need to go deeper. Go to openstreetmap.org, zoom into the city and try to find the transport line using the "query features" button on the right (an arrow with a question mark). Usually, OSM data are structured in a way that each direction of the line has its own relation (905096). These are then grouped in to "super-relation" (1676043), and those are finally grouped into a relation of all transport lines (376752). This way, you can save yourself some time - and after finding the first line, you can find the rest of them easily.
- After you found all the line relations (and super-relations), add them to wikidata.
- If there are wikidata IDs missing in the OSM relations, you need to edit the respective relations there and add the right wikidata tags. For the purpose of this template (Mapshapes), add the wikidata tag to the line relation (and optionally also super-relation). One of the ways is using the online editor. Find the relation, zoom sufficiently, hit the edit button and add/fix the wikidata tag.
See also
- {{mapframe}} - Template used to add a dynamic map to an article.
- {{mapmask}} - Used to create a mask using manually entered latitude/longitude pairs; useful for drawing city or region borders that aren't available from OpenStreetMap.