Vai al contenuto

Template:Maplink/sandbox

Da Wikipedia

<mapframe zoom="9">{"type": "FeatureCollection", "features": [

] }</mapframe> <maplink>{"type": "FeatureCollection", "features": [

] }</maplink><maplink>{"type": "FeatureCollection", "features": [

] }</maplink>

from OSM:

  • {{maplink|type=shape|id=}} (Wikidata id only required if another article's Wikidata page is to be used)
  • <maplink>: Il contenuto JSON non è un GeoJSON+simplestyle valido. L'elenco sotto mostra tutti i tentativi di interpretarlo secondo lo schema JSON. Non tutti sono errori.
    • /0/query: The property query is required
    • /0/ids: The property ids is required
    • /0: Failed to match at least one schema
    • /0/title: The property title is required
    • /0/service: Does not have a value in the enumeration ["page"]
    • /0: Failed to match exactly one schema
    • /0/geometries: The property geometries is required
    • /0/type: Does not have a value in the enumeration ["GeometryCollection"]
    • /0/type: Does not have a value in the enumeration ["MultiPolygon"]
    • /0/type: Does not have a value in the enumeration ["Point"]
    • /0/type: Does not have a value in the enumeration ["MultiPoint"]
    • /0/type: Does not have a value in the enumeration ["LineString"]
    • /0/type: Does not have a value in the enumeration ["MultiLineString"]
    • /0/type: Does not have a value in the enumeration ["Polygon"]
    • /0/coordinates: The property coordinates is required
    • /0/geometry: The property geometry is required
    • /0/type: Does not have a value in the enumeration ["Feature"]
    • /0/features: The property features is required
    • /0/type: Does not have a value in the enumeration ["FeatureCollection"]

    from OSM:

    • {{maplink|type=shape-inverse|id=}} (Wikidata id only required if another article's Wikidata page is to be used)
    • Fal Lua: Coordinates must be specified on Wikidata or in |coord=. (coordinates):
      ...from Wikidata:
      {{maplink|type=point|id=}} (Wikidata id only required if another article's Wikidata page is to be used)
      ...from specified coordinates:
      {{maplink|type=point|coord=}} (specify coordinates using {{Coord}} template)
    • Fal Lua: Pagina «Netherton Tunnel Branch Canal» non trovata. from a page or section ({{coord}} templates using the |name= parameter)
      ...from the current page: {{maplink|type=named}} or {{maplink|type=named|from=#Section}}
      ...from another page: {{maplink|type=named|from=Other page}} or {{maplink|type=named|from=Other page#Section}}
    • Fal Lua: Coordinates must be specified on Wikidata or in |coord=. (centred on a point's coordinates):
      ...from Wikidata:
      {{maplink|type=circle|radius=|id=}} (Wikidata id only required if another article's Wikidata page is to be used)
      ...from specified coordinates:
      {{maplink|type=circle|radius=|coord=}} (specify coordinates using {{Coord}} template)
    • To show in a frame, add the parameter |frame=yes: {{maplink|frame=yes|frame-align=left|type=line|id=Q1094308|text=Mapframe example}}.
      Map
      Mapframe example
    • Additional parameters are available to customise the displayed map, such as |plain=yes to remove the outer frame: {{maplink|frame=yes|frame-align=left|plain=yes|type=line|id={{get QID|Várkerület}}|frame-width=200|frame-height=250|frame-long=19.1009|frame-lat=47.5001|zoom=9}}.
      <mapframe>: Il contenuto JSON non è un GeoJSON+simplestyle valido. L'elenco sotto mostra tutti i tentativi di interpretarlo secondo lo schema JSON. Non tutti sono errori.
      • /0/query: The property query is required
      • /0/ids: The property ids is required
      • /0: Failed to match at least one schema
      • /0/title: The property title is required
      • /0/service: Does not have a value in the enumeration ["page"]
      • /0: Failed to match exactly one schema
      • /0/geometries: The property geometries is required
      • /0/type: Does not have a value in the enumeration ["GeometryCollection"]
      • /0/type: Does not have a value in the enumeration ["MultiPolygon"]
      • /0/type: Does not have a value in the enumeration ["Point"]
      • /0/type: Does not have a value in the enumeration ["MultiPoint"]
      • /0/type: Does not have a value in the enumeration ["LineString"]
      • /0/type: Does not have a value in the enumeration ["MultiLineString"]
      • /0/type: Does not have a value in the enumeration ["Polygon"]
      • /0/coordinates: The property coordinates is required
      • /0/geometry: The property geometry is required
      • /0/type: Does not have a value in the enumeration ["Feature"]
      • /0/features: The property features is required
      • /0/type: Does not have a value in the enumeration ["FeatureCollection"]
      • Overlays can also be displayed on top of the map: {{maplink|frame=yes|frame-align=left|frame-width=400|frame-height=300|type=point|id=Q8688|marker=airport|zoom=12 |text=San Francisco International Airport |overlay={{Graph:Street map with marks|width=110|height=90|lat=37.8|lon=-121.8|zoom=6|{ "lat": 37.618, "lon": -122.375 }| minimap=false}}}}
        Map
        San Francisco International Airport

      Parameter set – data page

      {{maplink
      |display=
      |from=
      |zoom=
      |text=
      |icon=
      }}
      

      Parameter set – raw data

      {{maplink
      |display=
      |raw= <!-- preferably {{Wikipedia:Map data/subpage}} -->
      |zoom=
      |text=
      |icon=
      }}
      

      Parameter set – geoline/geoshape

      {{maplink
      |display=
      |type=
      |id=
      |title=
      |description=
      |stroke-color=
      |stroke-width=
      |zoom=
      |text=
      |icon=
      }}
      

      Parameter set – point features/coordinates

      {{maplink
      |display=
      |type=point
      |id=
      |title=
      |description=
      |coord=
      |marker=
      |zoom=
      |text=
      |icon=
      }}
      


      Parameter set – circles

      {{maplink
      |display=
      |type=circle
      |radius=  <!-- in metres, alternative parameters available for other units --> 
      |id=
      |title=
      |description=
      |coord=
      |marker=
      |zoom=
      |text=
      |icon=
      }}
      

      Parameters

      [muda l codesc]

      For overall display

      [muda l codesc]
      display
      How the template is displayed. Valid values are:
      inline - Only displays the inline link (you can forego this, as it is the default)
      title - Only displays the title link
      inline,title - Displays the inline link as well as the title link
      title,inline - Same as above
      text
      Text to display for the link (or caption if using mapframe); default is "Map"
      icon
      Set to "no" to turn off the icon that appears next to the link
      zoom
      Zoom level, from 1 to 19 (larger numbers zoom in further); default is automatically determined by the map, unless the only feature is a single point.

      Mapframe parameters (only work with inline display)

      frame
      Set to "yes" to show a map frame instead of a link
      plain
      Set to "yes" to show just the map without the surrounding frame, and without a caption (text parameter will be ignored)
      frame-align
      Alignment with respect to the page: left, center, or right; default is right
      frame-width
      Width of the map frame, default is 300
      frame-height
      Height of the map frame, default is 200
      frame-coordinates
      (or frame-coord)
      Optional - alternate coordinates for initial placement of map. Use {{Coord}} template to specify coordinates (e.g. |frame-coordinates={{tl|Coord|12.34|S|56.78|W}}). If not set, coordinates will be retrieved from Wikidata.
      frame-latitude
      (or frame-lat)
      (ignored if |frame-coordinates= or |frame-coord= is set)
      Optional - alternate latitude coordinate for initial placement of map.
      frame-longitude
      (or frame-long)
      (ignored if |frame-coordinates= or |frame-coord= is set)
      Optional - alternate longitude coordinate for initial placement of map.
      Template:A note If frame latitude and longitude are not set by parameters, then frame coordinates can be determined automatically, either:
      • Based on the line and shape objects (if any have been specified), or
      • From the point feature specified in |coord= (if set), or
      • Retrieved from Wikidata (if available – for either the item specified in |id= parameter, or for the page the template is placed on)
      overlay
      An image, or another map, to be displayed on top the map. E.g.
      |overlay=[[File:Example.svg|140x140px]] or
      |overlay={{maplink|frame=yes|plain=yes|frame-width=100|frame-height=100|type=shape|id={{get QID|French submarine Ariane (1914)}}|frame-align=center}} or
      |overlay={{Graph:Street map with marks|width=100|height=100|lat=37.8|lon=-122.4|zoom=6|{ "lat": 37.8, "lon": -122.4 }|minimap=false}}
      (see Template:Maplink/testcases/overlays to view examples)
      overlay-horizontal-alignment
      Horizontal alignment of overlay, either left or right; default is right
      overlay-vertical-alignment
      Vertical alignment of overlay, either top or bottom; default is bottom
      overlay-horizontal-offset and overlay-vertical-offset
      Optional – number of pixels to offset the overlay in from the edge of the map, e.g. 10 for a 10 pixel gap
      overlay-border
      CSS style for the border, e.g. 3px solid black; default is 1px solid white. The colour can be any web color name or hex code.

      Raw GeoJSON

      [muda l codesc]
      raw
      Raw GeoJSON (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See below for more information.

      For each feature

      [muda l codesc]

      Multiple features can be displayed on a single map. For each additional feature, add a sequential number to the end of the parameter name. For example, the second uses parameters like |type2=, |id2=, etc., the third feature |type3=, |id3=, etc., and so on. Higher numbers are drawn on top.

      type
      Type of data. Valid values are:
      line – a geoline feature from OSM (e.g. a road)
      shape – a geoshape feature from OSM (e.g. a state or province)
      shape-inverse – a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath)
      data – a geoJSON data page on Commons (parameter is optional in this case)
      point – a point feature (coordinates)
      named – all named coordinates in an page or section ({{coord}} templates with |name= parameter)
      circle – a circle centred on a point's coordinates
      id
      (or ids)
      Wikidata id (Q-number) of the point feature, Wikidata id that the OSM line/shape feature is tagged with. Separate multiple ids with a comma. Defaults to the current page's Wikidata id (if |from= not set).
      from
      Source of map data:
      • If type is data or omitted: The JSON (.map) file from Commons to display (excluding the Data: prefix)
      • If type is named: Page name, or name#section, to get named coordinates from. If omitted, or specified as just #section, then current page will be used.
      title
      Title of the feature (for features from OSM), displayed when the feature is clicked on; default is the page title
      description
      Description of the feature (for features from OSM), displayed when the feature is clicked on; optional
      stroke-color
      (or stroke-colour)
      Color code for the color used to draw the feature (for features from OSM); default is #ff0000 (red)
      stroke-width
      Width for the lines used to draw the feature (for features from OSM); default is 6
      stroke-opacity
      Opacity for the lines used to draw the feature (for features from OSM) – a number between 0 (fully transparent) and 1 (fully opaque); default is 1
      fill
      Color code for the fill color of the feature (for shape or shape-inverse features from OSM); default is #000000 (black). Note that a semi-transparent version of the specified color will be used by default, allowing the map below to still be seen.
      fill-opacity
      Opacity for the fill color of the feature (for shape or shape-inverse features from OSM) – a number between 0 (fully transparent) and 1 (fully opaque); default is 0.5
      coord
      Coordinates to display for a point feature. Use {{Coord}} template to specify coordinates (e.g. |coord={{Coord|12.34|S|56.78|W}}). If not set, coordinates will be retrieved from Wikidata.
      marker
      Name of Maki marker image to display at the point feature. See mw:Maps/Icons for options. If not set, a plain marker will be shown without an image.
      marker-color
      (or marker-colour)
      Color code (Hex triplet) specifying marker background color. Default is 5E74F3 ( )
      marker-size
      Size of the marker. Can be small, medium (default) or large.
      radius
      (or radius_m), or alternative parameters radius_km, or radius_mi, or radius_ft
      Radius of the circle. In metres by default, or in kilometers or miles or feet if the alternative parameters are used.
      edges
      Number of edges used to construct the circle. Default is 32. Higher numbers will result in a smoother circle but use more Lua processing resources.

      TemplateData

      [muda l codesc]

      Adds a link, or frame, which will display map data

      Parametri template[Modifica dati del modello]

      ParametroDescrizioneTipoStato
      displaydisplay

      How the template is displayed

      Valori suggeriti
      inline title inline,title
      Predefinito
      inline
      Sconosciutofacoltativo
      texttext

      Text to display for the link (or caption if using mapframe)

      Predefinito
      Map
      Lineafacoltativo
      iconicon

      Set to "no" to turn off the icon that appears next to the link

      Booleanofacoltativo
      zoomzoom

      Zoom level, from 1 to 19 (larger numbers zoom in further); default is automatically determined by the map, unless the only feature is a single point.

      Numerofacoltativo

      Multiple map switcher

      [muda l codesc]

      An option for Template:Switcher-style switching of multiple mapframes, where specified parameters like zoom, or frame coordinates, or a shape's item id are switched between different values. When using, ensure the number of values in each list are the same.

      Instructions:

      1. Add parameter switch to specify labels for the different options: a list separated by either,, or ; if the labels contain commas, or ### if the labels contain semi-colons. Each label will be displayed with a prefix of "Show ".
        Example: |switch=zoomed out, zoomed mid, zoomed in
      2. For each parameter that is to be switched, set its value to SWITCH: followed by a list of values to switch between, again separated by , or ; or ###
        Example: |zoom=SWITCH:4,9,14
        Parameters frame, plain, and text should not be switched
      3. Make sure each list has the same number of entries. The position of value in a SWITCH: list corresponds to the same position in the list of labels set in |switch=.

      Example: Fal Lua: Coordinates must be specified on Wikidata or in |coord=.

      {{mapframe|frame=yes|type=point|id={{Get QID|French submarine Ariane (1914)}}|text=Boston|zoom=SWITCH:4,9,14|switch=zoomed out, zoomed mid, zoomed in}}

      Examples and tips

      [muda l codesc]

      Multiple features

      [muda l codesc]

      Multiple features allow you to:

      • Use external data from both Wikimedia Commons and OpenStreetMap together
      • Apply different styles to different external data features from OpenStreetMap
      • Include multiple links to external data from Wikimedia Commons
      Map
      Map
      {{Maplink|frame=yes
      |type=shape|id=Q3495894|title=Shape|description=Description of shape
      |type2=line|id2=Q1318331|title2=Line|description2=Description of line
      |type3=point|coord3={{coord|32|S|116|E}}|title3=Point|description3=Description of point
      }}
      

      Map

      {{Maplink|frame=yes|plain=yes|frame-width=250|frame-height=280|zoom=6|frame-lat=29.185|frame-long=76.225
      |type=shape-inverse|id=Q1174|title=Haryana
      |type2=point|id2=Q200663|stroke-width=3|title2=Faridabad
      }}
      

      Infoboxes

      [muda l codesc]

      Mapframes can be included in infoboxes. Using |plain=yes to remove the outer frame is recommended.

      For simple cases with a single feature, {{infobox mapframe}} can be used instead (see that template's documentation for details). Template:Infobox Australian road

      {{Infobox Australian road
      | location = {{maplink |type=line |frame=yes |plain=yes |frame-align=center |frame-lat=-31.8262 |frame-long=115.7877 |zoom=9}}
        ...  (other parameters omitted)  ...
      }}
      

      The raw parameter

      [muda l codesc]

      The "raw" parameter allows the same inputs as the full <maplink> function. It allows you to:

      • Use GeoJSON data directly
      • Use Wikidata queries to obtain information for the map
      • Use templates - if a map includes direct GeoJSON or many components, placing the data in a template will avoid cluttering the article text

      See mw:Help:Extension:Kartographer for instructions.

      Raw GeoJSON example

      [muda l codesc]
      <maplink>: Il JSON non può essere analizzato: Errore di sintassi
      {{maplink|raw={{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}|text=Route map}}
      

      (Link to GeoJSON data subpage: Wikipedia:Map data/Main Roads Western Australia/Forrest Highway)

      Raw Wikidata query examples

      [muda l codesc]
      Map
      Ten countries
      {{maplink|frame=yes|text=Ten countries|raw={
        "type": "ExternalData",
        "service": "geoshape",
        "query": "
      SELECT * WHERE {
        ?id wdt:P463 wd:Q1065 .
      } LIMIT 10
      "}
      |frame-width=600|frame-height=400|frame-lat=25|frame-long=10|zoom=1
      }}
      
      Map
      Map
      {{maplink|frame=yes|raw={
        "type": "ExternalData",
        "service": "geoshape",
        "query": "
      SELECT ?id ?head
        (SAMPLE(?img) as ?img_) 
        (min(?partyId) as ?party) 
        (if(?party = '0', '#800000', if(?party = '1', '#000080', '#008000')) as ?fill)
        (concat('[[', substr(str(?link),31,500),  '{{!}}', ?headLabel, ']]') as ?title)
        (concat(?stateLabel, '\\n', '[[File:', substr(str(?img_), 52, 500), '{{!}}200px]]') as ?description)
      WHERE {  
        ?id wdt:P31 wd:Q35657 .
        ?id wdt:P6 ?head .
        ?head wdt:P102 ?party .
        BIND(if(?party = wd:Q29468, '0', if(?party = wd:Q29552, '1', '2')) as ?partyId) 
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language 'en' .
          ?head rdfs:label ?headLabel .
          ?id rdfs:label ?stateLabel .
        }
        OPTIONAL {
          ?head wdt:P18 ?img .
        }
        ?link schema:about ?head .
        ?link schema:isPartOf <https://en.wikipedia.org/> .
      } GROUP BY ?id ?head ?headLabel ?link ?stateLabel
      "}|frame-width=600|frame-height=400|frame-lat=52|frame-long=-110|zoom=3}}
      

      Gotchas

      [muda l codesc]
      • When retrieving lines or shapes from OSM, you can't style the fill color or the opacity level of fills or strokes (unless you use the |raw= parameter)
      • The following code utilising the |raw= parameter won't work because the curly brace to close the GeoJSON is adjacent to the curly braces to close the template:
      {{Maplink|raw= {"type": "ExternalData","service": "geoshape","ids": "Q13518258"}}}
      To fix it, put a space before the two template braces or move them to a separate line.

      Tutorials

      [muda l codesc]

      Redirects

      [muda l codesc]
      • {{Map link}}
      • {{Mapframe}}

      See also

      [muda l codesc]