TotalBase
Widgets

Maps

A map of points from a query.

In the admin: a Dashboard › a widget › Edit

The Map draws the query's rows as points on a street map: Acme's sites with open orders, the fleet's latest positions. It uses the instance's map tiles, the same as a DataView's map. See Settings › Maps.

Sites with open work orders around Salta, red where an order is overdue.
Sites with open work orders around Salta, red where an order is overdue.

What it takes

RoleTakesUnset
Locationa point column: x is the longitude, y the latitudethe first point column
Latitude, Longitudetwo number columns, chosen by hand, when there's no point columnnone
Labelshown in a point's tooltipthe first column that isn't a number
Sizescales each circle: its area grows with the valuenone

A position always comes from a column's type, never its name. Rows with no position, or with coordinates out of range, are skipped. When none is left, the card says so. point(lng, lat) builds a point from two numbers.

Example

Acme's sites with open work orders, sized by how many, red when one is overdue:

SELECT s.name AS site, s.location,
       count(wo.id) AS open_orders,
       CASE WHEN bool_or(wo.due_at < now()) THEN 'red' ELSE 'emerald' END AS _color
FROM sites s
JOIN work_orders wo ON wo.site = s.id
WHERE wo.status NOT IN ('COMPLETED', 'CANCELLED')
  AND ($VAR.branch IS NULL OR s.branch = $VAR.branch::uuid)
GROUP BY s.id

Choose open_orders for Size. The _color column colors each point with a palette name and is never shown. GROUP BY s.id lets the query return the site's other columns: PostgreSQL knows they depend on its key, and a point can't be grouped by itself.

Settings

Setting
Group nearby pointsjoins points close together into a numbered circle
Formathow the Size value reads in a point's tooltip; unset, its column's format
Colorthe points' color; unset, the theme's primary
Color columna column whose palette name colors each point; unset, _color
On clickwhat a click on a point does: open the site's record, filter the dashboard by it

Tooltips are plain text: a value from the query is never read as HTML.

For the live fleet, query the vehicles_latest_positions view, and set the dashboard's auto-refresh so the map follows the vehicles while it's open.

Reference

MAP

Points on a street map - from a point column, or latitude and longitude.

Size: 6 × 5 of the 12-column grid, at least 3 × 3 · Also: events, export

DataCodeTakesRequiredUnset
LocationlocationpointfirstA point column (x = longitude, y = latitude). Defaults to the first point column.
LatitudelatitudenoneOnly without a point column - chosen by hand, with Longitude.
LongitudelongitudenoneOnly without a point column - chosen by hand, with Latitude.
LabellabelcategoryfirstShown on a point's tooltip. Defaults to the first column that isn't a number.
SizesizenumbernoneScales each point by this value. Optional.
PropertyCodeSectionValues
Group nearby pointsclusterappearancedefault falseJoins points close together into a numbered circle.
FormatdisplayFormatformatHow the Size value reads in a point's tooltip - a displayFormat pattern. Unset: its column's.
ColorcolorappearanceA palette hue for its marks - unset, the theme's primary.
Color columncolorColumnappearanceA column whose value - a palette name: red, emerald, amber... - colors its row's mark. Unset, a column named _color, if the query returns one.
On clickclickeventsWhat a click on a mark does: {action: "FILTER", variable, value} sets a variable of this dashboard; {action: "DATAVIEW", dataview, filter} opens a DataView filtered (the where grammar); {action: "DASHBOARD", dashboard, variables, tab}; {action: "RECORD", dataview, pk}; {action: "URL", url, newTab, inEmbeds}. Values are formulas over (_ columns too) and ; targets by id. hint: the tooltip's last line.
SELECT * FROM (VALUES ('Buenos Aires', point(-58.38, -34.60), 120), ('Córdoba', point(-64.18, -31.42), 80), ('Rosario', point(-60.65, -32.95), 60)) AS t(store, location, revenue)

Next steps