Card type
Map API
A map of a place, an area or several places, and distances between them: a WebKnox map image with the places marked, which works everywhere, plus the view, coordinates and outline a live map needs to show the same thing (see Maps). data.kind says which; data.approximate marks a region without fixed borders, whose view is WebKnox's estimate. Other places of the same name come as alternatives.
Card type map · version 1 · schema map.v1.schema.json
Layouts
Every card type has full. Pick a layout with the element's layout attribute, render.layout, or a theme.
Fields
The fields of card.data. Values a source doesn't provide are null; new optional fields can appear within version 1.
| Field | Type | Required | Notes |
|---|---|---|---|
title | string | yes | What the map shows, e.g. "Devon", "Southern England", "Hanseatic cities". |
subtitle | string | null | yes | One line saying what it is and where, in the answer's locale, e.g. "County in South West England, United Kingdom". |
kind | enum | yes | place: one point-like place (a city, a mountain) and the land around it; area: a region, county or country, with its outline when WebKnox has one; places: several places on one map (or the two ends of a distance). place · area · places |
approximate | boolean | yes | true when the view is WebKnox's estimate of a region without fixed borders ("southern England"): show it as approximate and draw no outline. |
view | object | yes | What the map shows. A live map fits this box; the static image shows the same box, widened to its own aspect ratio. |
view.bbox[] | number[] | yes | West, south, east and north edge in degrees (WGS 84), as in GeoJSON. south is below north; west is above east only for a box that crosses 180°. |
area | object | null | yes | The area the map is about, when it has a Wikidata item (an estimated region such as southern England keeps its id, with no outline), or the boundary of a place that has one in WebKnox's outlines (a city such as Berlin); null for other places, several places, or a region without an item. |
area.id | string | yes | Wikidata item of the area. |
area.outline | string | null | yes | The area's outline as GeoJSON, for a live map to draw; null when WebKnox has none. The static image already draws it. |
markers[] | object[] | yes | Places to mark, the asked ones first. An area may come without any. |
markers[].name | string | yes | |
markers[].lat | number | yes | |
markers[].lon | number | yes | |
markers[].role | enum | yes | subject: a place the question asked about (draw it as a pin; several for places and distances); capital: the country's capital; city: another place for orientation; poi: a sight or natural feature. subject · capital · city · poi |
markers[].id | string | null | yes | Wikidata item: a refine with {card: "map", id} shows a map of it, {card: "entity", id} its entity card. null when the place has none. |
lines[] | object[] | yes | Distances as the crow flies: a live map draws each as the great circle between the two markers. Empty unless the question was about a distance. |
lines[].from | integer | yes | Index into markers. |
lines[].to | integer | yes | Index into markers. |
lines[].km | number | yes | The great-circle distance in kilometres. |
lines[].label | string | yes | The distance as shown, in the request's units and the answer's locale, e.g. "253 km". |
static | object | yes | The view as a WebKnox map image with the markers to draw over it. x and y are in the image's own pixels (width × height), so they scale with it. Show this wherever script, WebGL or the host's rules keep a live map from loading, and until one has. |
static.src | string | yes | The image with labels for light styles. |
static.src_dark | string | yes | The same image with labels for dark styles (midnight). |
static.width | integer | yes | |
static.height | integer | yes | |
static.points[] | object[] | yes | The markers inside the image, in the markers' order. The image leaves their own labels out and keeps room for each name beside its point: draw each point with its name, except a name that would cover another, which a renderer may leave out if it names the place in text (the WebKnox element lists a map's places). |
static.points[].marker | integer | yes | Index into markers. |
static.points[].name | string | yes | |
static.points[].x | number | yes | |
static.points[].y | number | yes | |
static.points[].role | enum | yes | subject: a place the question asked about (draw it as a pin; several for places and distances); capital: the country's capital; city: another place for orientation; poi: a sight or natural feature. subject · capital · city · poi |
static.lines[] | object[] | yes | How to draw each of the lines on this image. |
static.lines[].line | integer | yes | Index into lines. |
static.lines[].path[] | number[][] | yes | The great circle as [x, y] pixel pairs; it may run past the image's edges, so clip it. |
static.inset | object | null | yes | A small country or world map that shows where the view is; null when the view is the whole world or a large part of it. |
static.inset.src | string | yes | A WebKnox country or world map: https://webknox.com/geo/v1/<ISO 3166-1 alpha-2>.svg, or world.svg. |
static.inset.width | integer | yes | |
static.inset.height | integer | yes | |
static.inset.frame[] | number[] | yes | x, y, width and height of the main view on this map, in its own pixels. A view that crosses 180° runs past the right edge of the world map: draw the part beyond it again from the left edge. |
relative[] | string[] | yes | Where it is in words, e.g. "253 km west of London". |
alternatives[] | object[] | yes | Other places with the same name, one refine away; the card shows the one most people look up. |
alternatives[].id | string | yes | |
alternatives[].name | string | yes | |
alternatives[].description | string | null | yes | |
attribution | string | yes | The map data's credit, e.g. "© OpenStreetMap contributors". The static image carries it; a live map must show it too. |
source_url | url | null | yes | A page about the place or area: its Wikipedia article, or its OpenStreetMap page. |
Example
A recorded answer to “Show Exeter on a map”. Open it in the Answer Lab to see every layout and style.
{
"v": 2,
"id": "ans_m4p3x7r2q9k6w1t8",
"matched": true,
"locale": "en",
"skill": "map",
"confidence": 0.9,
"text": "Exeter is a city in Devon, England, 253 km west of London.",
"speech": "Exeter is a city in Devon, England, 253 km west of London.",
"card": {
"type": "map",
"version": 1,
"data": {
"title": "Exeter",
"subtitle": "City in Devon, England",
"kind": "place",
"approximate": false,
"view": {
"bbox": [
-3.73,
50.64,
-3.33,
50.81
]
},
"area": null,
"markers": [
{
"name": "Exeter",
"lat": 50.7256,
"lon": -3.5269,
"role": "subject",
"id": "Q134672"
}
],
"lines": [],
"static": {
"src": "https://webknox.com/geo/v2/view.svg?b=-3.74,50.64,-3.32,50.82&w=600&h=406&l=en&t=light&o=Q134672&m=304_213_6",
"src_dark": "https://webknox.com/geo/v2/view.svg?b=-3.74,50.64,-3.32,50.82&w=600&h=406&l=en&t=dark&o=Q134672&m=304_213_6",
"width": 600,
"height": 406,
"points": [
{
"marker": 0,
"name": "Exeter",
"x": 304.4,
"y": 213.1,
"role": "subject"
}
],
"lines": [],
"inset": {
"src": "https://webknox.com/geo/v1/GB.svg",
"width": 440,
"height": 440,
"frame": [
208.9,
356.5,
8.7,
6.4
]
}
},
"relative": [
"253 km west of London"
],
"alternatives": [
{
"id": "Q990504",
"name": "Exeter",
"description": "Town in Rockingham County, New Hampshire, United States"
},
{
"id": "Q986815",
"name": "Exeter",
"description": "City in Tulare County, California, United States"
},
{
"id": "Q5420086",
"name": "Exeter",
"description": "Town in Tasmania, Australia"
}
],
"attribution": "© OpenStreetMap contributors",
"source_url": "https://en.wikipedia.org/wiki/Exeter"
}
},
"sources": [
{
"name": "OpenStreetMap",
"url": "https://www.openstreetmap.org/copyright",
"license": "ODbL"
},
{
"name": "Wikidata",
"url": "https://www.wikidata.org",
"license": "CC0"
},
{
"name": "Natural Earth",
"url": "https://www.naturalearthdata.com",
"license": "public domain"
}
],
"follow_ups": [
"Show me a map of Devon",
"What is the weather in Exeter?",
"Tell me about Exeter"
],
"actions": [],
"usage": {
"billable": true
}
}