Documentation

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.

FieldTypeRequiredNotes
titlestringyesWhat the map shows, e.g. "Devon", "Southern England", "Hanseatic cities".
subtitlestring | nullyesOne line saying what it is and where, in the answer's locale, e.g. "County in South West England, United Kingdom".
kindenumyesplace: 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
approximatebooleanyestrue when the view is WebKnox's estimate of a region without fixed borders ("southern England"): show it as approximate and draw no outline.
viewobjectyesWhat 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[]yesWest, 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°.
areaobject | nullyesThe 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.idstringyesWikidata item of the area.
area.outlinestring | nullyesThe area's outline as GeoJSON, for a live map to draw; null when WebKnox has none. The static image already draws it.
markers[]object[]yesPlaces to mark, the asked ones first. An area may come without any.
markers[].namestringyes
markers[].latnumberyes
markers[].lonnumberyes
markers[].roleenumyessubject: 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[].idstring | nullyesWikidata 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[]yesDistances 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[].fromintegeryesIndex into markers.
lines[].tointegeryesIndex into markers.
lines[].kmnumberyesThe great-circle distance in kilometres.
lines[].labelstringyesThe distance as shown, in the request's units and the answer's locale, e.g. "253 km".
staticobjectyesThe 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.srcstringyesThe image with labels for light styles.
static.src_darkstringyesThe same image with labels for dark styles (midnight).
static.widthintegeryes
static.heightintegeryes
static.points[]object[]yesThe 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[].markerintegeryesIndex into markers.
static.points[].namestringyes
static.points[].xnumberyes
static.points[].ynumberyes
static.points[].roleenumyessubject: 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[]yesHow to draw each of the lines on this image.
static.lines[].lineintegeryesIndex into lines.
static.lines[].path[]number[][]yesThe great circle as [x, y] pixel pairs; it may run past the image's edges, so clip it.
static.insetobject | nullyesA 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.srcstringyesA WebKnox country or world map: https://webknox.com/geo/v1/<ISO 3166-1 alpha-2>.svg, or world.svg.
static.inset.widthintegeryes
static.inset.heightintegeryes
static.inset.frame[]number[]yesx, 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[]yesWhere it is in words, e.g. "253 km west of London".
alternatives[]object[]yesOther places with the same name, one refine away; the card shows the one most people look up.
alternatives[].idstringyes
alternatives[].namestringyes
alternatives[].descriptionstring | nullyes
attributionstringyesThe map data's credit, e.g. "© OpenStreetMap contributors". The static image carries it; a live map must show it too.
source_urlurl | nullyesA 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.

Response
{
  "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
  }
}