Difference between revisions of "Template:Mapbox raw data/doc"

From blackwiki
Jump to navigation Jump to search
imported>Gareth
(add "below" parameter)
imported>Gareth
(Redirected page to Template:Mapbox/doc)
 
Line 1: Line 1:
{{Documentation subpage}}
+
#REDIRECT [[Template:Mapbox/doc]]
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
This is a version of [[Template:Mapbox]] that accepts raw map data. It allows the full power of <nowiki><maplink></nowiki> to be utilised.
 
 
 
==Usage==
 
<nowiki>{{Mapbox raw data}}</nowiki> styles a maplink and puts it in a box to the right of the page.
 
 
 
An example:
 
{{mapbox raw data|zoom=16|text=Example map using ''Mapbox raw data''|text-left=yes|data=
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
}}
 
<pre>
 
{{mapbox raw data|zoom=16|text=Example map using ''Mapbox raw data''|text-left=yes|data=
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
}}
 
</pre>
 
The same map using a standard <nowiki><maplink></nowiki>:
 
<maplink zoom="16" text="Example map using ''maplink''>
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
</maplink>
 
<pre>
 
<maplink zoom="16" text="Example map using ''maplink''">
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
</maplink>
 
</pre>
 
An example of <nowiki>{{Mapbox raw data}}</nowiki> with multiple links:
 
{{mapbox raw data|text-left=yes|above='''Multiple links within the one box'''
 
|text=External data from OpenStreetMap combined with GeoJSON|data=
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
|text2=External data from Commons|data2=
 
{
 
  "type": "ExternalData",
 
  "service": "page",
 
  "title": "Parramatta Light Rail.map"
 
}
 
|text3=External data from OpenStreetMap|data3=
 
{
 
  "type": "ExternalData",
 
  "service": "geoline",
 
  "ids": "Q6939836"
 
}
 
}}
 
<pre>
 
{{mapbox raw data|text-left=yes|above='''Multiple links within the one box'''
 
|text=External data from OpenStreetMap combined with GeoJSON|data=
 
[
 
  {
 
    "type": "ExternalData",
 
    "service": "geoshape",
 
    "ids": "Q13518258",
 
    "properties": {
 
      "stroke": "#ffb100",
 
      "stroke-width": 6,
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
 
    "properties": {
 
      "title": "Porte de Castellan"
 
    }
 
  },
 
  {
 
    "type": "Feature",
 
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
 
    "properties": {
 
      "title": "Porte Léon Roche"
 
    }
 
  }
 
]
 
|text2=External data from Commons|data2=
 
{
 
  "type": "ExternalData",
 
  "service": "page",
 
  "title": "Parramatta Light Rail.map"
 
}
 
|text3=External data from OpenStreetMap|data3=
 
{
 
  "type": "ExternalData",
 
  "service": "geoline",
 
  "ids": "Q6939836"
 
}
 
}}
 
</pre>
 
 
 
While ''[[Template:Mapbox]]'' and the similar ''[[Template:Maplink]]'' attempt to make simple maps easier to insert into a page, ''Mapbox raw data'' uses exactly the same data format for the map itself as the standard ''<nowiki><maplink></nowiki>'' function. Compared to ''[[Template:Mapbox]]'', ''Mapbox raw data'' can do the following:
 
*Use GeoJSON data directly
 
*Use a combination of data sources together (direct GeoJSON, external data from Wikimedia Commons and external data from OpenStreetMap)
 
*Style data (excluding data from Commons)
 
*Include multiple pieces of external data from Wikimedia Commons
 
*Use Wikidata queries to obtain information for the map
 
*Include up to five links within the one box
 
*Include non-linked explanatory text at the top of the box
 
 
 
==Parameters==
 
;text-left
 
:Set this to <code>yes</code> to change the text in the box from centre-aligned to left-aligned.
 
;above
 
:Text that appears above the links; useful for headings etc.
 
;below
 
:Text that appears below the links; useful for additional information.
 
 
 
The following parameters can be used to add up to five links in a single box by adding the numbers 2, 3, 4 or 5 to the end of the parameter name - e.g. <code>data2</code>, <code>text2</code>.
 
;data
 
:A link to external data from Wikimedia Commons or OpenStreetMap and/or any valid GeoJSON data; the template's only required parameter. The parameter also accepts templates that contain any code that would normally go in the parameter, e.g.{{tl|Map of Sydney Ferries wharves}}.
 
;text
 
:Text to display for the link; default is "View map" (or "Use the text''n'' parameter to specify the text of this link" when a numbered version of the data parameter is used).
 
;zoom
 
:Zoom level, from <code>1</code> to <code>18</code> (larger numbers zoom in further); will be automatically determined if not set.
 
;latitude
 
;longitude
 
:Specify the centre point of the map; will be automatically determined if not set.
 
 
 
==Gotchas==
 
The following code won't work because the curly brace to close the data field is on the same line as the curly braces to close the template:
 
<pre>{{Mapbox raw data|data= {"type": "ExternalData","service": "geoshape","ids": "Q13518258"}}}</pre>
 
To fix it, put the two template braces on a separate line.
 
 
 
== See also ==
 
*[[Template:Attached KML]]
 
<includeonly>{{sandbox other||
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
[[Category:Coordinates templates]]
 
[[Category:Exclude in print]]
 
}}</includeonly>
 

Latest revision as of 07:04, 12 May 2018