Help:Map Data

From Celeste Wiki
Jump to navigation Jump to search

<languages/> Template:Tocright Template:PD Help Page Map data allows users to store GeoJSON data on wiki, similar to images. Other wikis may use this data to draw on top of the maps, together with other map customizations.

To create a new map data, go to Wikimedia Commons, and create a new page in the Data namespace with the .map suffix, such as Data:Sandbox/Name/Example.map. Feel free to experiment by creating pages with the Sandbox/<username>/ prefix. For now, page content can only be edited in the raw JSON format. Eventually, we hope there will be a powerful editor to simplify GeoJSON creation (you can enable the c:User:0x010C/KartoEditor gadget to edit them directly or use the geojson website and then copy the GeoJSON data).

<translate>

Data licensing[edit source]

</translate> All data in the Data: namespace must licensed under one of the following licences:

  • CC0-1.0
  • CC-BY versions: CC-BY-1.0, CC-BY-2.0, CC-BY-2.5, CC-BY-3.0, CC-BY-4.0, CC-BY-4.0+
  • CC-BY-SA versions: CC-BY-SA-1.0, CC-BY-SA-2.0, CC-BY-SA-2.5, CC-BY-SA-3.0, CC-BY-SA-4.0, CC-BY-SA-4.0+
  • ODbL-1.0

The default license is empty string (e.g invalid license) and when a user tries to save page with invalid license, they will be notified of the allowed licenses.

<translate>

Top-level fields[edit source]

</translate> Map data has several required and optional top-level elements:

  • The required "license" field must always be set to one of the allowed string values, e.g. "CC0-1.0" (see #Data licensing).
  • The optional "description" field must be set to a localized string value - an object with at least one key-value, where the key is a language code (e.g. "en"), and the value is a description string.
  • The optional "sources" field must be a Wiki markup string value that describes the source of the map data.
  • The optional "zoom" field must be an integer between 0 and 18. This value is only used for displaying map on its own page, not when including it in the articles.
  • The optional "latitude" and "longitude" fields specify the center of the map when displaying it on its own page, not when including it in the articles.
  • The required "data" field must be set to the valid GeoJSON content. Per GeoJSON specification, "properties" field may be set for every Feature object. The map data will use all of the Simple Style properties, such as "title", "description", "fill" (color), and others. Additionally, the "title" and "description" fields may be either strings or localized string objects (similar to the localized type in tabular data). This allows the same map data to appear differently depending on the user's language.

<translate>

Usage[edit source]

</translate>

  • Use <mapframe> and <maplink> tags to show a map together with the custom map data defined in the .map page. For that, add this wiki markup (or similar <maplink> but without the width and height) to any wiki page in any project, and the content of the Data:Sample.map page from Commons will be drawn. The content will be localized based on the user's interface language settings.
<mapframe width=500 height=350 zoom=11 latitude=40.8 longitude=-74>
{
  "type": "ExternalData",
  "service": "page",
  "title": "Sample.map"
}
</mapframe>
  • While not a very common usage scenario, a Lua script on any wiki can get map data by calling mw.ext.data.get("Example.map"). The function returns data in almost the same format as the original JSON, except that all localized strings will be converted to regular strings, and the license field will also include a localized license name. To get the data in another language, pass language code as the second parameter. To get the data in the original, unmodified form, use "_" as the language code.

<translate>

Examples[edit source]

</translate> <mapframe width=400 height=400 zoom=11 latitude=40.7920 longitude=-73.9751> {

 "type": "ExternalData",
 "service": "page",
 "title": "Neighbourhoods/New York City.map"

} </mapframe>

Simple map[edit source]

<mapframe width=200 height=200 zoom=11>
{
  "type": "ExternalData",
  "service": "page",
  "title": "Neighbourhoods/New York City.map"
}
</mapframe>

<translate>

Map in Infobox[edit source]

</translate>

|map={{maplink|frame=yes|plain=yes|frame-align=center|frame-width=290|frame-height=200|type=line|from=Neighbourhoods/New York City.map}}
|map_custom=yes

<translate>

Sample map data[edit source]

</translate>

{
    "license": "CC0-1.0",
    "description": { "en": "Manhattan Neighborhoods" },
    "sources": "http://example.com and [[Data]] page",
    "zoom": 11,
    "latitude": 40.8,
    "longitude": -74,
    "data": {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": {
                    "title": {"en":"Alphabet City", "ru":"Алфабет-сити"}
                },
                "geometry": {
                    "type": "Polygon",
                    "coordinates": [[
                    	[-73.980356454849,40.730425548938],
    ...

<translate>

Restrictions and gotchas[edit source]

</translate>

  • Each string value except the "sources" must be no more than 400 symbols long. Special characters like new lines \n and tabs \t are not allowed.
  • The overall size of the page may not exceed 2MB.
  • Retrieving lines or shapes via Wikidata IDs within a data page will cause the map to break when it is called via maplink or mapframe. A workaround is to add the IDs directly in the maplink or mapframe code:
<mapframe width="500" height="500">
 [
  {
   "type": "ExternalData",
   "service": "geoshape",
   "ids": "Qxxxxx"
  },
  {
   "type": "ExternalData",
   "service": "page",
   "title": "Sample.map"
  }
 ]
</mapframe>

The sources are drawn in the order in which they are listed in the code - in the example above, the geoshape from Wikidata will appear beneath the components from the data page. This would be reversed if the data page was called before the Wikidata ID.

<translate>

See also[edit source]

</translate>

  • P3896 - property for linking to .map pages from a related Wikidata item
  • Wikidata:Map data
  • Tabular data - similarly structured tabular data in the Data: namespace on commons.

[[Category:Help{{#translation:}}]] [[Category:Extension help{{#translation:}}]] [[Category:Mapping{{#translation:}}]]