Template:Map with marks/doc: Difference between revisions

Content deleted Content added
No edit summary
rm parent cats
 
(27 intermediate revisions by 10 users not shown)
Line 1:
{{documentation subpage}}
{{Uses TemplateStyles|Template:Map with marks/styles.css}}
Shows an image of a map, and draws user-specified images/icons on top of it using latitude/longitude coordinates.
{| class="wikitable"
|-
! Markup
! Result
|-
| '''Simple map with a single marker, custom size, and no minimap'''<br>
{{sxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | width=400 | height=150 | lat=37.8 | lon=-122.4 | zoom=5 | minimap=false |
 
{ "lat": 37.8, "lon": -122.4 }
 
}}</nowiki> | lang=wikitext}}
| {{ {{BASEPAGENAME}} | width=400 | height=150 | lat=37.8 | lon=-122.4 | zoom=5 | minimap=false |
{ "lat": 37.8, "lon": -122.4 }
}}
|-
| '''Two markers with labels - one as diamond shape, one uses an image from Commons'''<br>''Text label can be customized with all of [https://github.com/vega/vega/wiki/Marks#text Vega text mark] parameters by prepending "text" to their name''<br>
{{#tag:syntaxhighlightsxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | lat=40.816667 | lon=14.433333 | zoom=6 |
 
{"lat": 40.816667, "lon": 14.433333, "imgshape": "wikirawupload:{{filepath:Volcano red 32x32.svg|32}}diamond", "width": 16, "heightsize": 1670, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"},
 
{"lat": 40.948333, "lon": 15.635556, "img": "wikirawupload:{{filepath:Volcano red 32x32.svg|32}}", "width": 16, "height": 16, "offsetY": -20, "text": "Mount Vulture", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}
 
}}</nowiki> | lang=jsonwikitext}}
| {{ {{BASEPAGENAME}} | lat=40.948333 | lon=15.635556 | zoom=6 |
{"lat": 40.816667, "lon": 14.433333, "imgshape": "wikirawupload:{{filepath:Volcano red 32x32.svg|32}}diamond", "width": 16, "heightsize": 1670, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"},
 
{"lat": 40.948333, "lon": 15.635556, "img": "wikirawupload:{{filepath:Volcano red 32x32.svg|32}}", "width": 16, "height": 16, "offsetY": -20, "text": "Mount Vulture", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}
}}
|-
| '''SimpleOne mapmarker with alabels singleon marker,a andblank no minimapmap'''<br>
{{#tag:syntaxhighlightsxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | latstyle=37.8osm | lonlat=-12240.4816667 | zoomlon=514.433333 | minimapzoom=false6 |
 
{"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"},
{ "lat": 37.8, "lon": -122.4 }
 
}}</nowiki> | lang=jsonwikitext}}
| {{ {{BASEPAGENAME}} | latstyle=37.8osm | lonlat=-12240.4948333 | zoomlon=515.635556 | minimapzoom=false6 |
{"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"},
{ "lat": 37.8, "lon": -122.4 }
}}
|-
| '''Data from Commons Dataset'''<br>''Same as above, but this time the data is stored on Commons in a table [[commons:Data:Sandbox/Yurik/Street map with marks sample.tab|Data:Sandbox/Yurik/Street map with marks sample.tab]]''<br>
| '''Show all Armenian heritage sites''', by querying it from Wikidata<br>
{{#tag:syntaxhighlightsxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | lat=40.347948333 | lon=4715.260635556 | zoom=6 | colorScaleFieldtable=typeSandbox/Yurik/Street map with marks sample.tab}}</nowiki> | wdqslang=wikitext}}
| {{ {{BASEPAGENAME}} | lat=40.948333 | lon=15.635556 | zoom=6 | table=Sandbox/Yurik/Street map with marks sample.tab}}
|-
| '''Show all Armenian heritage sites''', by querying it from Wikidata<br>''The query result should have the same columns (fields) as in the other examples (<code>text, img, ...</code>), except coordinates should be returned as <code>coord</code> column''
{{sxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | lat=40.347 | lon=47.260 | zoom=6 | colorScaleField=type | wdqs=
# Each ___location should show only once. This query may output all the same values as in the other examples, such as "text", "img", and others.
SELECT (SAMPLE(?coord) as ?coord) (SAMPLE(?type) as ?type)
Line 50 ⟶ 67:
}}
|-
| {{#tag:syntaxhighlightsxhl |<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki> | lat=-33.8688 | lon=151.2093 | zoom=10 |
{
"lat": -33.8688,
"lon": 151.2093,
"img": "wikirawupload:{{filepath:Opera_House_and_ferry._Sydney.jpg|48}}",
"width": 48,
"height": 36,
Line 64 ⟶ 81:
"textDx": -30
}
}}</nowiki> | lang=jsonwikitext}}
| {{ {{BASEPAGENAME}} | lat=-33.8688 | lon=151.2093 | zoom=10 |
{
"lat": -33.8688,
"lon": 151.2093,
"img": "wikirawupload:{{filepath:Opera_House_and_ferry._Sydney.jpg|48}}",
"width": 48,
"height": 36,
Line 82 ⟶ 99:
|}
 
The data template parameter must be a comma separated list of "JSON" objects. Each object starts with a "{", has a list of comma separated key-value pairs, and ends with a "}". The key may be one of the following values (used no more than once per each object):
 
{| class="wikitable"
! colspan="2" |Built-in marker shapes
|-
|shape
|"circle" (default), "square", "cross", "diamond", "triangle-up", "triangle-down" ([https://github.com/vega/vega/wiki/Marks#symbol docs])
|-
| color || shape fill color, e.g. "#ff0000" (red - default)
|-
| strokeColor
|shape outline color
|-
|size
|shape size (number)
|-
! colspan="2" |Text labels (see [https://github.com/vega/vega/wiki/Marks#text more info])
|-
| text
|Label text
|-
| textAlign
|Label's horizontal alignment relative to the marker - "left", "right", "center". By default, left for LTR, right for RTL languages.
|-
| textBaseline
|Vertical alignment: "middle" (default), "top", "bottom"
|-
| textColor
|Label text color, e.g. "#ff0000" (red)
|-
| textDx, textDy
|Horizontal and vertical distance from the marker
|-
|angle
|Draw text at an angle
|-
|radius/theta
|Radial positioning of the label relative to the marker
|-
|font, fontSize, fontWeight, fontStyle
|Font name, size, boldness, and style
|-
! colspan="2" |Image markers
|-
| img || URL of an image, e.g. <nowiki>wikirawupload:{{filepath:Volcano red 32x32.svg|32}}</nowiki>
|-
| height, width
|Size of the image
|-
| offsetX, offsetY
|Shift the center of the image on the map
|}
 
==See also==
* [[Template:Location map]]
* [[Template:OSM Location map]] - to use this mapping template with standard wikipedia syntax
* [[Template:Query map]] - automtically produce a map showing all of a certain type of thing in a certain area, e.g. lighthouses in Cornwall.
 
==Template data==
<templatedata>
{
Line 126 ⟶ 202:
"description": "If set, 0 or false will always hide the map, and 1 or true will always show it. Make sure the map is big enough include the minimap. By default, the map will be shown for zoom levels 5+ if the map is sufficiently large",
"type": "boolean"
},
"lang": {
"description": "The language code of the language to use to draw the labels on the map. Use special value 'local' to draw the labels in the language of the area being depicted. Uses the page language by default.",
"type": "string"
}
},
"paramOrder": [
Line 136 ⟶ 216:
"lon",
"zoom",
"lang",
"wdqs",
"colorScaleField",
Line 143 ⟶ 224:
}
</templatedata>
{{Graph, chart and plot templates|cat=no}}
<includeonly> {{sandbox other||
[[Category:Graph Template Collection]]
}} </includeonly>