Template:Map with marks/doc
This is a documentation subpage for Template:Map with marks. It contains usage information, categories and other content that is not part of the original template page. |
Lua error in package.lua at line 80: module 'Module:Uses TemplateStyles/config' not found. Shows an image of a map, and draws user-specified images/icons on top of it using latitude/longitude coordinates.
Markup | Result |
---|---|
Simple map with a single marker, custom size, and no minimap <syntaxhighlight lang="json">{{Map with marks | width=400 | height=150 | lat=37.8 | lon=-122.4 | zoom=5 | minimap=false | { "lat": 37.8, "lon": -122.4 } }} </syntaxhighlight> |
Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 150, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "37.8"} }, {"name":"imgLon", "init": {"expr": "-122.4"} }, {"name":"imgZoom", "init": {"expr": "5"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "false"} } ], "data": [ { "name": "data", // Otherwise use the first unnamed argument for source values "values": [ { "lat": 37.8, "lon": -122.4 } ], "transform": [ { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "color" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
Two markers with labels - one as diamond shape, one uses an image from Commons Text label can be customized with all of Vega text mark parameters by prepending "text" to their name <syntaxhighlight lang="json">{{Map with marks | lat=40.816667 | lon=14.433333 | zoom=6 | {"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}, {"lat": 40.948333, "lon": 15.635556, "img": "Volcano red 32x32.svg", "width": 16, "height": 16, "offsetY": -20, "text": "Mount Vulture", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"} }} </syntaxhighlight> |
Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 300, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "40.948333"} }, {"name":"imgLon", "init": {"expr": "15.635556"} }, {"name":"imgZoom", "init": {"expr": "6"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "imgZoom>4 && imgWidth>200 && imgHeight>110"} } ], "data": [ { "name": "data", // Otherwise use the first unnamed argument for source values "values": [ {"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}, {"lat": 40.948333, "lon": 15.635556, "img": "Volcano red 32x32.svg", "width": 16, "height": 16, "offsetY": -20, "text": "Mount Vulture", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"} ], "transform": [ { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "color" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
One marker with labels on a blank map <syntaxhighlight lang="json">{{Map with marks | style=osm | lat=40.816667 | lon=14.433333 | zoom=6 | {"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}, }} </syntaxhighlight> |
Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 300, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "40.948333"} }, {"name":"imgLon", "init": {"expr": "15.635556"} }, {"name":"imgZoom", "init": {"expr": "6"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "imgZoom>4 && imgWidth>200 && imgHeight>110"} } ], "data": [ { "name": "data", // Otherwise use the first unnamed argument for source values "values": [ {"lat": 40.816667, "lon": 14.433333, "shape": "diamond", "size": 70, "offsetY": -10, "text": "Mount Vesuvius", "textFontWeight": "bold", "textFontSize": 16, "textColor": "#2A4B8D"}, ], "transform": [ { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'+'&style=osm'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "color" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
Data from Commons Dataset Same as above, but this time the data is stored on Commons in a table Data:Sandbox/Yurik/Street map with marks sample.tab <syntaxhighlight lang="json">{{Map with marks | lat=40.948333 | lon=15.635556 | zoom=6 | table=Sandbox/Yurik/Street map with marks sample.tab}} </syntaxhighlight> |
Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 300, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "40.948333"} }, {"name":"imgLon", "init": {"expr": "15.635556"} }, {"name":"imgZoom", "init": {"expr": "6"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "imgZoom>4 && imgWidth>200 && imgHeight>110"} } ], "data": [ { "name": "data", // Use tabular data source "url": "tabular:///Sandbox%2FYurik%2FStreet%20map%20with%20marks%20sample.tab", "format": {"type": "json", "property": "data"}, "transform": [ { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "color" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
Show all Armenian heritage sites, by querying it from Wikidata The query result should have the same columns (fields) as in the other examples ( text, img, ... ), except coordinates should be returned as coord column
<syntaxhighlight lang="sparql">{{Map with marks | 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) WHERE { ?item wdt:P3170 ?heritageId . ?item wdt:P625 ?coord . ?item wdt:P31 ?type . } GROUP BY ?item }} </syntaxhighlight> |
Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 300, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "40.347"} }, {"name":"imgLon", "init": {"expr": "47.260"} }, {"name":"imgZoom", "init": {"expr": "6"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "imgZoom>4 && imgWidth>200 && imgHeight>110"} } ], "data": [ { "name": "data", // If query parameter is given, use it to get data from Wikidata Query service // Assume that it contains "coord" field with the geo coordinates "url": "wikidatasparql:///?query=%23%20I%20couldn%27t%20get%20type%20to%20show%20as%20text%0ASELECT%20%28SAMPLE%28%3Fcoord%29%20as%20%3Fcoord%29%20%28SAMPLE%28%3Ftype%29%20as%20%3Ftype%29%0AWHERE%20%7B%0A%20%20%3Fitem%20wdt%3AP3170%20%3FheritageId%20.%0A%20%20%3Fitem%20wdt%3AP625%20%3Fcoord%20.%0A%20%20%3Fitem%20wdt%3AP31%20%3Ftype%20.%0A%7D%0AGROUP%20BY%20%3Fitem", "format": {"type": "json"}, "transform": [ // If query is given, translate geo coordinate [longitude, latitude] array into two values { "type": "formula", "field":"lon", "expr": "datum.coord[0]" }, { "type": "formula", "field":"lat", "expr": "datum.coord[1]" }, { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], "scales": [ { "name": "sColor", "type": "ordinal", "range": "category10", "domain": {"data": "data", "field": "type"} } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "type", "scale": "sColor" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
<syntaxhighlight lang="json">{{Map with marks | lat=-33.8688 | lon=151.2093 | zoom=10 | { "lat": -33.8688, "lon": 151.2093, "img": "Opera_House_and_ferry._Sydney.jpg", "width": 48, "height": 36, "text": "Sydney", "textFontWeight": "bold", "textFontSize": 20, "textColor": "#00f", "textAlign": "right", "textDx": -30 } }} </syntaxhighlight> | Page Template:Map with marks/styles.css has no content.<graph>
{ // Ported from English Wikipedia // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Street_map_with_marks // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab // "version": 2, "width":400, "height": 300, "padding": 0, "signals":[ // These signals allow us to quickly move the map within the image, e.g. to leave space for the legend {"name":"legendWidth", "init": {"expr": "0"} }, {"name":"legendHeight", "init": {"expr": "height"} }, {"name":"imgWidth", "init": {"expr": "width-legendWidth"} }, {"name":"imgHeight", "init": {"expr": "height"} }, {"name":"imgXC", "init": {"expr": "imgWidth/2"} }, {"name":"imgYC", "init": {"expr": "imgHeight/2"} }, {"name":"imgTileSize", "init": {"expr": "256"} }, {"name":"imgLat", "init": {"expr": "-33.8688"} }, {"name":"imgLon", "init": {"expr": "151.2093"} }, {"name":"imgZoom", "init": {"expr": "10"} }, {"name":"picWidth", "init": {"expr": "180"} }, {"name":"picHeight", "init": {"expr": "picWidth/2"} }, {"name":"picXC", "init": {"expr": "imgWidth-(picWidth/2)"} }, {"name":"picYC", "init": {"expr": "imgHeight-(picHeight/2)"} }, {"name":"showMiniMap", "init": {"expr": "imgZoom>4 && imgWidth>200 && imgHeight>110"} } ], "data": [ { "name": "data", // Otherwise use the first unnamed argument for source values "values": [ { "lat": -33.8688, "lon": 151.2093, "img": "Opera_House_and_ferry._Sydney.jpg", "width": 48, "height": 36, "text": "Sydney", "textFontWeight": "bold", "textFontSize": 20, "textColor": "#00f", "textAlign": "right", "textDx": -30 } ], "transform": [ { "type": "geo", "projection": "mercator", "scale": {"expr": "imgTileSize/PI/2*pow(2,imgZoom)"}, "translate": [{"expr": "imgXC"}, {"expr": "imgYC"}], "center": [{"expr": "imgLon"}, {"expr": "imgLat"}], "lon": "lon", "lat": "lat" }, { "type": "formula", "field":"layout_x", "expr": "datum.layout_x + (datum.offsetX || 0)" }, { "type": "formula", "field":"layout_y", "expr": "datum.layout_y + (datum.offsetY || 0)" }, { "type": "formula", "field":"color", "expr": "datum.color || '#c33'" }, { "type": "formula", "field":"textColor", "expr": "datum.textColor || datum.color" }, { "type": "formula", "field":"strokeColor", "expr": "datum.strokeColor || '#ffe7e6'" } ] }, { // Hack: single value data source for drawing/hiding images and other non-series elements "name": "dummyData", "values": [{}] } ], // Legend only works if showLegend and colorScaleField are set "marks": [ { "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "formula", "field":"url", "expr": "'mapsnapshot:///?width='+imgWidth+'&height='+imgHeight+'&zoom='+imgZoom+'&lat='+imgLat+'&lon='+imgLon+'&lang=en'" } ] }, "properties": { "enter": { "url": {"field": "url"}, "xc": {"signal": "imgXC"}, "yc": {"signal": "imgYC"}, "width": {"signal": "imgWidth"}, "height": {"signal": "imgHeight"} } } }, { // Places an image of a given name and size at the [lan,lon] location "type": "image", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.img" }, { "type": "formula", "field":"iconWidth", "expr": "datum.width || 0" }, { "type": "formula", "field":"iconHeight", "expr": "datum.height || 0" }, { "type": "formula", "field":"img", "expr": "if(!test(/^[a-z]+:\\/\\//, datum.img), 'wikifile:///'+datum.img, datum.img)" }, // Ensure that either width or height parameter is passed to wikifile:// request { "type": "formula", "field":"img", "expr": "if((datum.iconWidth || datum.iconHeight) && !test(/[?&](width|height)=\\d/, datum.img),if(datum.iconWidth,datum.img+'?width='+datum.iconWidth,datum.img+'?height='+datum.iconHeight), datum.img)" } ]}, "properties": { "enter": { "url": {"field": "img"}, "xc": {"field": "layout_x"}, "yc": {"field": "layout_y"}, "width": {"field": "iconWidth"}, "height": {"field": "iconHeight"} } } }, { // Draw marks of a given color, shape, and size at the [lan,lon] location "type": "symbol", "from": { "data": "data", "transform": [{ "type": "filter", "test": "!datum.img" }] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, // If colorScaleField is set, use color scaling, otherwise use the preset color value "fill": { "field": "color" }, "size": {"field": "size"}, "shape": {"field": "shape"}, "stroke": {"field": "strokeColor"} } } }, { // Draw text with the given color and size at the [lan,lon] location // See https://github.com/vega/vega/wiki/Marks#text for all parameter description (prepend "text" and capitalize them) "type": "text", "from": { "data": "data", "transform": [ { "type": "filter", "test": "datum.text" }, // Figure out if this is an LTR or RTL page. For LTR, show label to the right of the icon, left-aligned. For RTL, reverse. { "type": "formula", "field":"isLTR", "expr": "'' == '\\u200E'" }, // If these values are not defined ("undefined" is not allowed, so test for truthiness and not 0) { "type": "formula", "field":"textDx", "expr": "if(!datum.textDx && datum.textDx != 0, if(datum.isLTR,8,-8), datum.textDx)" }, { "type": "formula", "field":"textAlign", "expr": "if(!datum.textAlign, if(datum.isLTR,'left','right'), datum.textAlign)" }, { "type": "formula", "field":"textBaseline", "expr": "datum.textBaseline || 'middle'" } ]}, "properties": { "enter": { "text": {"field": "text"}, "x": {"field": "layout_x" }, "y": {"field": "layout_y"}, "dx": {"field": "textDx" }, "dy": {"field": "textDy"}, "fill": {"field": "textColor"}, "align": {"field": "textAlign"}, "baseline": {"field": "textBaseline"}, "radius": {"field": "textRadius"}, "theta": {"field": "textTheta"}, "angle": {"field": "textAngle"}, "font": {"field": "textFont"}, "fontSize": {"field": "textFontSize"}, "fontWeight": {"field": "textFontWeight"}, "fontStyle": {"field": "textFontStyle"} } } }, { // Draw a low-zoom locator map frame "type": "rect", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" } ] }, "properties": { "enter": { "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth", "offset":2}, "height": {"signal": "picHeight"}, "stroke": {"value":"#fff"},"strokeWidth": {"value":6} } } }, { // Draw a low-zoom locator map by using a premade world map image "type": "image", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"url", "expr": "1" } ] }, "properties": { "enter": { "url": {"value": "wikirawupload:https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Earthmap1000x500.jpg/180px-Earthmap1000x500.jpg"}, "xc": {"signal": "picXC"}, "yc": {"signal": "picYC"}, "width": {"signal": "picWidth"}, "height": {"signal": "picHeight"} } } }, { // Draw a zoom-out mark at the [lan,lon] location "type": "symbol", "from": { "data": "dummyData", "transform": [ { "type": "filter", "test": "showMiniMap" }, { "type": "formula", "field":"lat", "expr": "imgLat" }, { "type": "formula", "field":"lon", "expr": "imgLon" }, { "type": "geo", "projection": "equirectangular", "scale": {"expr": "180/2/PI"}, "translate": [{"expr": "picXC"}, {"expr": "picYC"}], "center": [{"expr": "0"}, {"expr": "0"}], "lon": "lon", "lat": "lat" } ] }, "properties": { "enter": { "x": {"field": "layout_x"}, "y": {"field": "layout_y"}, "fill": {"value": "#c33"}, "stroke": {"value": "#ffe7e6"}, "size": {"value": 40} } } } ] } </graph> |
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):
Built-in marker shapes | |
---|---|
shape | "circle" (default), "square", "cross", "diamond", "triangle-up", "triangle-down" (docs) |
color | shape fill color, e.g. "#ff0000" (red - default) |
strokeColor | shape outline color |
size | shape size (number) |
Text labels (see 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 |
Image markers | |
img | URL of an image, e.g. wikirawupload:{{filepath:Volcano red 32x32.svg|32}} |
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> { "params": { "1": { "label": "data", "description": "Comma separated list of JSON objects that describing what data to draw on the map", "type": "string", "suggested": true }, "width": { "description": "Total width of the graph", "type": "number" }, "height": { "description": "Total height of the graph", "type": "number", "default": "Half of the width" }, "padding": { "type": "number" }, "lat": { "description": "Latitude of the map's center", "type": "number" }, "lon": { "description": "Longitude of the map's center", "type": "number" }, "zoom": { "description": "Map zoom level (0..18)", "type": "number" }, "wdqs": { "description": "An optional Wikidata query to use instead of the data - the query would generate a list of items just like data, but it must contain a \"coord\" field with the location", "type": "string" }, "colorScaleField": { "description": "If given, this data field will be used to make dots of different color, one color per unique value of this field", "type": "string" }, "minimap": { "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": [ "1", "width", "height", "padding", "lat", "lon", "zoom",
"lang",
"wdqs", "colorScaleField", "minimap" ], "description": "Shows an image of a map, and draws user-specified images/icons on top of it using latitude/longitude coordinates." } </templatedata> Template:Graph, chart and plot templates