Elicit.js

Geo

Geo marks place rows by longitude and latitude through a chart-level projection, instead of x/y scales. Frame any place by fitting GeoJSON or a lon/lat bounding box in projection.domain, or by passing a live d3.geo* instance with your own center and scale. geoBasemap({ geojson }) draws vector maps and geoTile() lays Web Mercator raster tiles behind your marks.

API reference

projection (ElicitSpec)

Chart option. Accepts a named projection (fits the world), an options object fitted to a GeoJSON domain, or a live d3.geo* instance (required when setting center / scale directly). It frames the first view; zoom and pan move the view through the lon and lat domains. Auto axes default off when set.

projection: "mercator" | "albers-usa" | "equal-earth" | "orthographic" | …
projection: { type, domain?, rotate?, parallels?, clipAngle?, precision?, inset?, … }
projection: d3.geoMercator().center([lon, lat]).scale(s).translate([w / 2, h / 2])
Options
OptionType · defaultDescription
type
string | fn
Named projection (e.g. "mercator", "albers-usa", "equal-earth", "orthographic", "identity") or a d3.geo* factory.
domain
GeoJSONdefault{ type: "Sphere" }
GeoJSON FeatureCollection, Feature, or Geometry fitted into the plot frame. Pass { type: "MultiPoint", coordinates: [[w, s], [e, n]] } to frame a lon/lat box with no polygon winding issues.
inset / insetTop / …
numberdefault0
Pixel padding inside the plot frame when fitting domain.
rotate
[λ, φ, γ?]
Spherical rotation in degrees. Pass [-lon, -lat] to centre a globe or conic projection on [lon, lat].
parallels / clipAngle / precision
d3-geodefault— / — / 0.15
Forwarded to the underlying d3-geo projection.

geoBasemap({ geojson, … })

Inert background map. Pass topology as a mark option — geojson — not as Elicit data. Load your own: const map = await fetch("…").then(r => r.json()) then geoBasemap({ geojson: map }). A FeatureCollection draws one path per feature so boundaries show.

geoBasemap({ geojson, fill, stroke, strokeWidth, id }) → Mark
Options
OptionType · defaultDescription
geojson
GeoJSON
FeatureCollection, Feature, or Geometry. Required for a visible basemap.
fill / stroke / strokeWidth
styledefault'#e2e8f0' / '#94a3b8' / 0.75
Chrome styling (also via channels).

geoTile({ url, … })

Raster basemap from a slippy-map tile server (OSM, CARTO, satellite, or your own). Requires projection: "mercator" or a d3.geoMercator() instance: tiles are pre-rendered in Web Mercator, so other projections draw nothing and log a warning. Inert chrome, like geoBasemap — compose both to draw boundaries over imagery.

geoTile() → Mark  // OSM standard + attribution
geoTile({ url, subdomains, tileSize, opacity, attribution, attributionSize, minZoom, maxZoom, zoomOffset, id }) → Mark
Options
OptionType · defaultDescription
url
string | fndefaultOSM standard
Template {s}/{z}/{x}/{y}, or a function of the tile.
subdomains
string[]default[]
Hosts to rotate {s} across (e.g. a, b, c).
opacity
numberdefault1
Dim the imagery so overlaid data reads.
attribution
string | nulldefault"© OpenStreetMap contributors"
Drawn bottom-right. A licence condition of every tile service — only pass null if you render the credit yourself.
attributionSize
numberdefault9
Attribution font size in px.
zoomOffset / minZoom / maxZoom
numberdefault0 / 0 / 19
Nudge or clamp the chosen zoom level (picked from the fitted scale).
tileSize
numberdefault256
Edge length of one tile in px. Set it for a server that serves retina tiles.
Returns / emits

A mark emitting image nodes into the background layer, keyed by {z}/{x}/{y} so on-screen tiles survive a re-render without re-fetching.

geoPoint / geoPolygon / geoLine / geoText / geoRect

Editable overlays. Import plot from elicitjs. geoText is text with the projection doing the placement — it shares the node shape, so editText / cycle / rotate work on it unchanged.

geoPoint({ channels: { lon, lat, size, fill }, edits }) → Mark
geoPolygon({ channels: { geometry, fill } }) → Mark  // one region per row, drawn from GeoJSON
geoPolygon({ channels: { lon, lat, series }, handles, handleSize, handleColor }) → Mark  // one region across rows; a vertex is a row
geoLine({ channels: { lon, lat, series, order }, handles, handleSize, handleColor, closed }) → Mark  // one line across rows; a vertex is a row
geoLine({ channels: { coordinates }, handles }) → Mark  // one line per row, drawn from a list
geoText({ channels: { lon, lat, text }, dx, dy, format }) → Mark
geoRect({ channels: { west, south, east, north } }) → Mark
Options
OptionType · defaultDescription
closed
booleandefaultfalse
geoLine with lon/lat channels: join the last vertex to the first and fill the region. A geoPolygon with those channels is this form. On the coordinates form it logs a warning.
handles / handleSize / handleColor
boolean | 'hit' / number / stringdefaulthandles where an edit reaches the row / 5 / the line's stroke
Vertex handles on geoLine and a lon/lat geoPolygon, as on line. true draws one at every vertex, false draws none, and "hit" keeps them grabbable but unseen. A line from a coordinates cell draws them only when you set handles. A geometry geoPolygon has no vertex rows, so these options log a warning there.
format
string | fndefaultString
geoText display formatter for the text channel. Display-only.
Channels
ChannelTypeDescription
lon / lat
quantitative
Position in degrees. One dot per row on geoPoint, the anchor on geoText; on geoLine, connects the rows into one path; on geoPolygon, into one closed region.
geometry
GeoJSON
geoPolygon path geometry on each row. Drawn as given; to edit vertices use lon / lat rows.
coordinates
[[lon,lat],…]
geoLine vertex list, one line per row. Drawn as given; to edit vertices use lon / lat rows.
text
string
geoText label content (raw, unscaled). Retype it with editText().
fontSize / textAnchor / lineAnchor / angle
literal
geoText glyph channels — same as the text mark.
dx / dy
px
geoText visual nudge off the anchor (does not move the lon/lat a drag writes).
west/south/east/north
quantitative
geoRect geographic AABB.
fill / stroke / size
style
Ordinary style scales (not projected).
Returns / emits

Marks emitting path / circle / text / rect nodes in projected pixel space.

edit.geo.*

Geo-scoped edits (scope: "geo"). Each is a universal edit on the map’s channels: move, create, line.draw, line.moveSeries and brushRect. They write lon/lat through the chart projection, and a declared domain on those fields limits them. Delete a pin, a vertex or a box with remove.

edit.geo.move() — drag a geoPoint, a geoText or a geoLine vertex
edit.geo.create() — click to place a lon/lat row
edit.geo.draw({ minDist }) — drag to draw a geoLine or geoPolygon, a row per vertex (minDist: 8 px between vertices)
edit.geo.moveSeries() — drag a whole geoLine, or a geoPolygon by its inside
edit.geo.brush({ resize, move, edgeInset }) — resize/move a geoRect (resize: 'both' | 'x' | 'y' | 'none')
edit.geo.createRect({ width, height, edgeInset }) — click open map to mint a bbox (degrees)

Framing a location

A bare projection name such as projection: "mercator" fits the whole world. Point the map at a specific place in one of three ways:

  • Fit a GeoJSON object: projection: { type: "mercator", domain: geojson, inset: 6 }. Any FeatureCollection, Feature, or Geometry fills the plot frame. Note that d3-geo treats clockwise exterior rings as the interior of a polygon (opposite to RFC 7946), so a reversed polygon zooms out to the globe and logs a warning.
  • Fit a lon/lat bounding box (no GeoJSON needed): pass a MultiPoint of the southwest and northeast corners as domain: domain: { type: "MultiPoint", coordinates: [[west, south], [east, north]] }. A MultiPoint has no ring winding, so it fits any rectangle reliably.
  • Centre on [lon, lat] and zoom level: pass a live d3.geoMercator() instance directly as projection. Options such as center and scale belong on a d3.geo* instance rather than the plain projection options object. For Web Mercator tiles, slippy-map zoom level z converts directly to scale with (256 * 2 ** z) / (2 * Math.PI), and translate([innerWidth / 2, innerHeight / 2]) puts center in the middle of the plot.

For globe or regional projections such as "orthographic" or "conic-conformal", pass rotate: [-lon, -lat] in the projection options object to centre on [lon, lat].

lon and lat are placed through the projection, so their schema entries only need { type: "quantitative" }. Declare a domain on either to bound where a pin can be dropped or dragged. With zoom and pan, the domains hold the window on show.

Frame any region with a bounding box

Pass two opposite corners as a GeoJSON MultiPoint in projection.domain. Swap the two pairs to move the map anywhere on Earth.

// Fit the map to any region by passing its southwest and northeast corners
// as a GeoJSON MultiPoint — no GeoJSON polygon file or ring-winding needed.
const londonBounds = {
type: "MultiPoint",
coordinates: [
[-0.22, 51.46], // [west, south]
[ 0.02, 51.56], // [east, north]
],
};
const chart = Elicit({
width: 520, height: 360,
margins: { top: 0, right: 0, bottom: 0, left: 0 },
projection: { type: "mercator", domain: londonBounds },
data: [
{ lon: -0.1276, lat: 51.5072, place: "Westminster" },
],
schema: {
lon: { type: "quantitative" },
lat: { type: "quantitative" },
place: { type: "categorical" },
},
marks: [
geoTile(),
geoPoint({
size: 7, fill: "#EE7B5E", stroke: "#fff", strokeWidth: 2,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create({ defaults: { place: "new pin" } })],
}),
],
});
mount(chart.dom());
Try: Click the map to drop a pin; drag any pin to move it.

Centre on coordinates and switch locations

A live d3.geoMercator() with .center([lon, lat]), .scale(scaleForZoom(z)) and .translate([W / 2, H / 2]) frames the first view. A button writes the lon and lat domains with setDomain() to jump to a new city.

const W = 520, H = 360;
// Web Mercator slippy-map zoom level z → d3.geoMercator scale.
// Roughly: z = 4 continent, z = 11 city, z = 15 neighbourhood or campus.
const scaleForZoom = (z) => (256 * 2 ** z) / (2 * Math.PI);
const PLACES = {
Tokyo: { center: [139.6917, 35.6895], zoom: 11, pins: [{ lon: 139.7006, lat: 35.6896, place: "Shinjuku" }, { lon: 139.7671, lat: 35.6812, place: "Tokyo Station" }] },
London: { center: [-0.1276, 51.5072], zoom: 11, pins: [{ lon: -0.1276, lat: 51.5072, place: "Westminster" }, { lon: -0.0759, lat: 51.5055, place: "Tower Bridge" }] },
"New York":{ center: [-73.9857, 40.7484], zoom: 11, pins: [{ lon: -73.9857, lat: 40.7484, place: "Midtown" }, { lon: -73.9654, lat: 40.7829, place: "Central Park" }] },
Vancouver: { center: [-123.1207, 49.268], zoom: 12, pins: [{ lon: -123.1207, lat: 49.2827, place: "Downtown" }, { lon: -123.1560, lat: 49.2680, place: "Kitsilano" }] },
};
// A projection centred on [lon, lat] at slippy-map zoom z.
const projectionAt = (center, zoom) => d3.geoMercator()
.center(center)
.scale(scaleForZoom(zoom))
.translate([W / 2, H / 2]);
// Pass a live d3.geoMercator() instance to frame the first view.
const proj = projectionAt(PLACES.Tokyo.center, PLACES.Tokyo.zoom);
const chart = Elicit({
width: W, height: H,
margins: { top: 0, right: 0, bottom: 0, left: 0 },
projection: proj,
data: PLACES.Tokyo.pins,
schema: {
lon: { type: "quantitative" },
lat: { type: "quantitative" },
place: { type: "categorical" },
},
marks: [
geoTile(),
geoPoint({
size: 7, fill: "#EE7B5E", stroke: "#fff", strokeWidth: 2,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create({ defaults: { place: "new pin" } })],
}),
],
});
mount(chart.dom());
const controls = document.createElement("div");
controls.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:10px;font:12px system-ui";
const readout = document.createElement("span");
readout.style.color = "#6F8294";
// The lon and lat window a centre and a zoom level show.
const windowAt = (center, zoom) => {
const p = projectionAt(center, zoom);
return {
lon: [p.invert([0, H / 2])[0], p.invert([W, H / 2])[0]],
lat: [p.invert([W / 2, H])[1], p.invert([W / 2, 0])[1]],
};
};
// The lon and lat domains are the map's view, so setDomain() moves it.
const goTo = (name) => {
const { center, zoom, pins } = PLACES[name];
const { lon, lat } = windowAt(center, zoom);
chart.setDomain("lon", lon);
chart.setDomain("lat", lat);
chart.setData(pins);
readout.textContent = `${name} · [${center[0].toFixed(2)}, ${center[1].toFixed(2)}] · z${zoom}`;
};
for (const name of Object.keys(PLACES)) {
const b = document.createElement("button");
b.textContent = name;
b.onclick = () => goTo(name);
b.style.cssText = "padding:4px 10px;border:1px solid #BCC9D4;border-radius:6px;background:transparent;color:inherit;cursor:pointer";
controls.append(b);
}
controls.append(readout);
mount(controls);
readout.textContent = `Tokyo · [${PLACES.Tokyo.center[0].toFixed(2)}, ${PLACES.Tokyo.center[1].toFixed(2)}] · z${PLACES.Tokyo.zoom}`;
Try: Click a city button to reframe the map · click the map to drop a pin · drag a pin to move it.

Zooming and panning

A map zooms and pans with the same view edits as any chart: view: { edits: [edit.view.zoom(), edit.view.pan()] }. The wheel zooms about the place under the pointer. A drag on open map pans; a drag on a pin, vertex or study box still edits that mark.

On a map the view edits write the lon and lat domains, and the projection moves to show that window. So a map view is undoable, and chart.setDomain("lon", [west, east]) with chart.setDomain("lat", [south, north]) sets it from a button. chart.setDomain("lon", null) restores the declared domain, or the view the projection framed when none is declared.

  • Limits: min and max are zoom levels, as multiples of the view the projection frames. A declared lon or lat domain is the widest window the view reaches; limit: false lifts it.
  • Both axes: a projection places longitude and latitude together, so a map moves both. channels and minSpan have no effect.
  • Projections: the window is exact on a cylindrical projection such as "mercator" or "equirectangular". On a conic or azimuthal projection the view fits the window's bounding box, so it shows a little more at the corners.
  • Sizes: pins, strokes and labels keep their pixel size. edit.view.zoom({ mode: "magnify" }) scales them with the map. geoTile() and geoBasemap() keep their stroke width in both modes.

Set margins: { top: 0, right: 0, bottom: 0, left: 0 } so tiles, vector outlines and marks clip to the frame. Raster tiles load at the zoom level on show.

Zoom and pan an OpenStreetMap basemap

edit.view.zoom({ min, max }) and edit.view.pan() in the view. The buttons write the same lon and lat domains with setDomain().

const W = 520, H = 360;
const scaleForZoom = (z) => (256 * 2 ** z) / (2 * Math.PI);
// The home view: Tokyo at slippy-map zoom 11. Zoom and pan never change it.
const HOME_ZOOM = 11;
const proj = d3.geoMercator()
.center([139.6917, 35.6895])
.scale(scaleForZoom(HOME_ZOOM))
.translate([W / 2, H / 2]);
// Zoom levels are multiples of the home view: out to z2, in to z18.
const [MIN, MAX] = [2 ** (2 - HOME_ZOOM), 2 ** (18 - HOME_ZOOM)];
const chart = Elicit({
width: W, height: H,
margins: { top: 0, right: 0, bottom: 0, left: 0 },
projection: proj,
data: [
{ lon: 139.7006, lat: 35.6896, place: "Shinjuku" },
],
schema: {
lon: { type: "quantitative" },
lat: { type: "quantitative" },
place: { type: "categorical" },
},
// The same view edits as any chart. Tiles load at the zoom level on show.
view: {
edits: [edit.view.zoom({ min: MIN, max: MAX }), edit.view.pan()],
},
marks: [
geoTile(),
// A drag on a pin still moves the pin; a drag on open map pans.
geoPoint({
size: 7, fill: "#EE7B5E", stroke: "#fff", strokeWidth: 2,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [
edit.geo.move(),
edit.geo.create({ defaults: { place: "new pin" } }),
],
}),
],
});
mount(chart.dom());
// The window on show: the lon and lat domains, or the home view before any zoom.
const edge = (x, y) => proj.invert([x, y]);
const HOME = {
lon: [edge(0, H / 2)[0], edge(W, H / 2)[0]],
lat: [edge(W / 2, H)[1], edge(W / 2, 0)[1]],
};
const windowNow = () => {
const s = chart.getSchema();
return { lon: s.lon.domain || HOME.lon, lat: s.lat.domain || HOME.lat };
};
const levelNow = () => {
const [lo, hi] = windowNow().lon;
return (HOME.lon[1] - HOME.lon[0]) / (hi - lo);
};
// A button writes the same domains the wheel does.
const zoomBy = (k) => {
const level = levelNow() * k;
if (level < MIN || level > MAX) return;
const win = windowNow();
for (const field of ["lon", "lat"]) {
const [lo, hi] = win[field];
const mid = (lo + hi) / 2;
const half = (hi - lo) / 2 / k;
chart.setDomain(field, [mid - half, mid + half]);
}
};
const controls = document.createElement("div");
controls.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:10px;font:12px system-ui";
const readout = document.createElement("span");
readout.style.color = "#6F8294";
const addButton = (label, onclick) => {
const b = document.createElement("button");
b.textContent = label;
b.onclick = onclick;
b.style.cssText = "padding:4px 10px;border:1px solid #BCC9D4;border-radius:6px;background:transparent;color:inherit;cursor:pointer";
controls.append(b);
};
addButton("Zoom in", () => zoomBy(1.5));
addButton("Zoom out", () => zoomBy(1 / 1.5));
// null takes the written domain away: the map draws as the projection framed it.
addButton("Reset", () => { chart.setDomain("lon", null); chart.setDomain("lat", null); });
controls.append(readout);
mount(controls);
const show = () => {
const { lon, lat } = windowNow();
const z = HOME_ZOOM + Math.log2(levelNow());
readout.textContent = `z${z.toFixed(1)} · [${((lon[0] + lon[1]) / 2).toFixed(3)}, ${((lat[0] + lat[1]) / 2).toFixed(3)}]`;
};
chart.on("change", show);
show();
Try: Scroll to zoom · drag open map to pan · drag a pin to move it · click open map to add a pin.

Zoom and pan a GeoJSON basemap

The projection is fitted to the GeoJSON once. Zoom and pan write the lon and lat domains; Reset takes them away with setDomain(field, null).

const W = 520, H = 360, PAD = 12;
// The home view: a projection fitted to the GeoJSON. Zoom and pan never change it.
const proj = d3.geoMercator().fitExtent([[PAD, PAD], [W - PAD, H - PAD]], vancouver);
const [MIN, MAX] = [0.6, 12];
const chart = Elicit({
width: W, height: H,
margins: { top: 0, right: 0, bottom: 0, left: 0 },
projection: proj,
data: [
{ lon: -123.1207, lat: 49.2827, place: "Downtown" },
],
schema: {
lon: { type: "quantitative" },
lat: { type: "quantitative" },
place: { type: "categorical" },
},
// The same view edits as any chart. On a map they write the lon and lat
// domains, and the projection moves to show that window.
view: {
edits: [edit.view.zoom({ min: MIN, max: MAX }), edit.view.pan()],
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#46596B", strokeWidth: 0.8 }),
geoPoint({
size: 7, fill: "#50AEB7", stroke: "#fff", strokeWidth: 1.5,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [
edit.geo.move(),
edit.geo.create({ defaults: { place: "new pin" } }),
],
}),
],
});
mount(chart.dom());
// The window on show: the lon and lat domains, or the home view before any zoom.
const edge = (x, y) => proj.invert([x, y]);
const HOME = {
lon: [edge(0, H / 2)[0], edge(W, H / 2)[0]],
lat: [edge(W / 2, H)[1], edge(W / 2, 0)[1]],
};
const windowNow = () => {
const s = chart.getSchema();
return { lon: s.lon.domain || HOME.lon, lat: s.lat.domain || HOME.lat };
};
const levelNow = () => {
const [lo, hi] = windowNow().lon;
return (HOME.lon[1] - HOME.lon[0]) / (hi - lo);
};
// A button writes the same domains the wheel does.
const zoomBy = (k) => {
const level = levelNow() * k;
if (level < MIN || level > MAX) return;
const win = windowNow();
for (const field of ["lon", "lat"]) {
const [lo, hi] = win[field];
const mid = (lo + hi) / 2;
const half = (hi - lo) / 2 / k;
chart.setDomain(field, [mid - half, mid + half]);
}
};
const controls = document.createElement("div");
controls.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:10px;font:12px system-ui";
const readout = document.createElement("span");
readout.style.color = "#6F8294";
const addButton = (label, onclick) => {
const b = document.createElement("button");
b.textContent = label;
b.onclick = onclick;
b.style.cssText = "padding:4px 10px;border:1px solid #BCC9D4;border-radius:6px;background:transparent;color:inherit;cursor:pointer";
controls.append(b);
};
addButton("Zoom in", () => zoomBy(1.5));
addButton("Zoom out", () => zoomBy(1 / 1.5));
// null takes the written domain away: the map draws as the projection framed it.
addButton("Reset", () => { chart.setDomain("lon", null); chart.setDomain("lat", null); });
controls.append(readout);
mount(controls);
const show = () => { readout.textContent = `${levelNow().toFixed(1)}×`; };
chart.on("change", show);
show();
Try: Scroll to zoom · drag open map to pan · drag or click to edit pins.

Providing basemap data

geoBasemap draws the map and cannot be edited. Pass it GeoJSON, and pass the same object as projection.domain so the map fills the frame. The examples below use Vancouver's 22 local areas (vancouver in the docs scope); your app imports or fetches its own file.

Vancouver local areas

Pass any FeatureCollection: geoBasemap({ geojson }). Fit with projection.domain. In your app: const map = await fetch("…/my-map.geojson").then(r => r.json()).

// docs inject `vancouver`; your app loads GeoJSON then passes it in:
// const vancouver = await fetch("data/vancouver-neighborhoods.json").then(r => r.json());
const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [],
schema: {},
marks: [
geoBasemap({
geojson: vancouver,
fill: "#EDF7F8",
stroke: "#46596B",
strokeWidth: 0.8,
}),
],
});
mount(chart.dom());

Real basemaps (OSM raster tiles)

geoTile() lays a raster basemap — a pyramid of 256px tiles from a tile server — behind your marks. Tiles are pre-rendered in Web Mercator, so it requires projection: "mercator" or a d3.geoMercator() instance; other projections draw nothing and log a warning instead of a misaligned map. Lon/lat marks and edit.geo.* gestures work the same on top, because they use the same projection. Every tile service requires attribution as a licence condition, and geoTile() draws it by default. Public OSM tiles are rate-limited, so in production point url at your own server or a paid provider.

Pins on OpenStreetMap

geoTile() replaces geoBasemap, so no GeoJSON is needed. Fit the view with a two-corner MultiPoint in projection.domain.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 0, right: 0, bottom: 0, left: 0 },
// No GeoJSON needed: fit the projection to a two-corner lon/lat box.
projection: {
type: "mercator",
domain: {
type: "MultiPoint",
coordinates: [
[-123.225, 49.198], // [west, south]
[-123.023, 49.297], // [east, north]
],
},
},
data: [
{ lon: -123.1207, lat: 49.2827, place: "Downtown" },
{ lon: -123.1560, lat: 49.2680, place: "Kitsilano" },
],
schema: {
lon: { type: "quantitative" },
lat: { type: "quantitative" },
place: { type: "categorical" },
},
marks: [
geoTile(), // defaults to OSM standard + its attribution
geoPoint({
size: 7, fill: "#EE7B5E", stroke: "#fff", strokeWidth: 2,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create({ defaults: { place: "new pin" } })],
}),
],
});
mount(chart.dom());
Try: Click to drop a pin; drag it. Lon/lat come back as data.

Tiles under the neighbourhood outlines

geoTile() lays the imagery, geoBasemap() draws the boundaries over it (fill "none"), and the elicited marks sit on top of both. Dim the tiles with opacity so your data stays readable.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [{ name: "study area", west: -123.140, south: 49.275, east: -123.100, north: 49.290 }],
schema: {
name: { type: "categorical" },
west: { type: "quantitative", domain: [-123.27, -123.02] },
south: { type: "quantitative", domain: [49.20, 49.32] },
east: { type: "quantitative", domain: [-123.27, -123.02] },
north: { type: "quantitative", domain: [49.20, 49.32] },
},
marks: [
// A lighter, less busy basemap than OSM standard. Any {z}/{x}/{y} server works.
geoTile({
url: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
subdomains: ["a", "b", "c"],
opacity: 0.85,
attribution: "© OpenStreetMap · © CARTO",
}),
// Vector boundaries on top of the imagery.
geoBasemap({ geojson: vancouver, fill: "none", stroke: "#20555A", strokeWidth: 0.8 }),
geoRect({
fill: "rgba(80, 174, 183, 0.18)", stroke: "#37919B", strokeWidth: 1.5,
channels: {
west: { field: "west" },
south: { field: "south" },
east: { field: "east" },
north: { field: "north" },
},
edits: [
edit.geo.brush({ edgeInset: 10 }),
edit.geo.createRect({ width: 0.024, height: 0.014, defaults: { name: "new area" } }),
],
}),
],
});
mount(chart.dom());
Try: Drag a study box; click open map to add one.

Place and move points on the map

geoPoint places a row at its lon/lat through the projection. Click empty space to add a point, and drag one to move it. Lon/lat come back through onChange and getData().

Pins on Vancouver

Seeded near Downtown & Kitsilano; click elsewhere to add more.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [
{ lon: -123.1207, lat: 49.2827, label: "Downtown" },
{ lon: -123.1560, lat: 49.2680, label: "Kits" },
],
schema: {
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
label: { type: "categorical" },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#46596B", strokeWidth: 0.8 }),
geoPoint({
size: 8, fill: "#50AEB7", stroke: "#fff", strokeWidth: 1.5,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create()],
}),
],
});
mount(chart.dom());
Try: Click to place a pin; drag an existing one.

Label and rename places

geoText is a text mark positioned by the projection instead of x/y scales. Every other text behaviour carries over: editText() to retype the content, cycle() to advance a categorical label, rotate() on angle. Pair it with a geoPoint that reads the same rows, and the label follows when you drag the dot. dx/dy offset the text from its anchor and leave the lon/lat unchanged.

Named pins you can rename

geoPoint carries the drag; geoText carries the label. editText() opens an inline editor on double-click and writes the string back to the row.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [
{ lon: -123.1207, lat: 49.2827, place: "Downtown" },
],
schema: {
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
place: { type: "categorical" },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#6F8294", strokeWidth: 0.7 }),
geoPoint({
size: 6, fill: "#1B3F60", stroke: "#fff", strokeWidth: 1.5,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create({ defaults: { place: "new place" } })],
}),
// The label: same rows, positioned by the same projection, nudged above the dot.
geoText({
dy: -12, fontSize: 12, fill: "#20555A",
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
text: { field: "place" },
},
edits: [editText({ channel: "text" })],
}),
],
});
mount(chart.dom());
Try: Double-click a name to retype it · drag a dot (the label follows) · click the map to add a pin.

Recolour neighbourhoods

Regions you already have are dataset rows with a geometry field: the basemap features you want answers for, copied into the data. The basemap underneath stays as it is. To reshape a region, see Regions you can reshape.

Cycle fill on selected local areas

Kitsilano, Fairview, Mount Pleasant, Downtown — click to cycle category.

const editable = vancouver.features
.filter(f => ["Kitsilano", "Fairview", "Mount Pleasant", "Downtown"].includes(f.properties.name))
.map(f => ({
name: f.properties.name,
geometry: f.geometry,
fill: "A",
}));
const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: editable,
schema: {
name: { type: "categorical" },
fill: { type: "categorical", domain: ["A", "B", "C"] },
geometry: { type: "categorical" },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#6F8294", strokeWidth: 0.7 }),
geoPolygon({
stroke: "#20555A", strokeWidth: 1.2, fillOpacity: 0.75,
channels: {
geometry: { field: "geometry", scale: null },
fill: {
field: "fill",
scale: { scheme: "dd" },
edit: cycle(),
},
},
}),
],
});
mount(chart.dom());
Try: Click a shaded neighbourhood to cycle its colour.

Draw lines over the city

A geoLine with lon/lat channels draws one line across the rows, so each vertex is a row. edit.geo.draw adds a row at every step of a drag. Give the mark a series channel and each stroke starts a new line. edit.geo.move drags a vertex by its handle, and remove deletes one. Put draw and move on one mark: press a handle to reshape, or drag anywhere else to draw.

Draw a path across Vancouver

Each stroke is one route. Every vertex is a row with its own lon and lat.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [],
schema: {
route: { type: "categorical" }, // the series key: one per stroke
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#46596B", strokeWidth: 0.8 }),
geoLine({
stroke: "#EE7B5E", strokeWidth: 2.5, handleSize: 4,
channels: {
series: { field: "route" },
lon: { field: "lon" },
lat: { field: "lat" },
},
// Press a vertex to move it; drag anywhere else to draw.
edits: [edit.geo.draw(), edit.geo.move()],
}),
],
});
mount(chart.dom());
Try: Drag across the map to sketch a route · drag a vertex to reshape it.

Reshape a seeded Broadway line

Five seeded rows, one per vertex. edit.geo.move() drags each by its handle.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
// One row per vertex, in the order they connect.
data: [
{ lon: -123.185, lat: 49.264 },
],
schema: {
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#46596B", strokeWidth: 0.8 }),
geoLine({
stroke: "#EE7B5E", strokeWidth: 2.5, handleSize: 6,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move()],
}),
],
});
mount(chart.dom());
Try: Drag a vertex handle.

Connected scatter over the map

A geoLine and a geoPoint over the same rows draw a trail and its stops. Dragging a stop re-derives the trail. Rows connect in array order. An order channel sorts them by a column, and a series channel draws one trail per group.

For a line you already have, give geoLine a coordinates channel (a [[lon, lat], …] list on each row) or a geometry channel (a GeoJSON LineString). It draws one line per row.

A route across Vancouver

Five stops connected in `stop` order. The dots are a geoPoint mark with edit.geo.move(). The trail follows because both marks read the same dataset.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [
{ stop: 1, lon: -123.1850, lat: 49.2720, place: "Kitsilano" },
],
schema: {
stop: { type: "quantitative" },
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
place: { type: "categorical" },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#6F8294", strokeWidth: 0.7 }),
// The connector: lon/lat channels -> one path across the rows, in `stop` order.
geoLine({
stroke: "#EE7B5E", strokeWidth: 2,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
// `order` is a channel: it names the column the trail is sorted by.
order: { field: "stop" },
},
}),
// The stops: their own feature, so a drag lands on one dot.
geoPoint({
size: 6, fill: "#EE7B5E", stroke: "#fff", strokeWidth: 1.5,
channels: {
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [edit.geo.move(), edit.geo.create({ defaults: { place: "new stop" } })],
}),
],
});
mount(chart.dom());
Try: Drag a stop to reroute; click the map to append one.

Regions you can reshape

Give geoPolygon lon/lat channels and it draws a closed region across the rows, a row per vertex. A series channel draws one region per group. edit.geo.move drags a vertex, edit.geo.moveSeries drags the whole region by its inside, and remove deletes a vertex. edit.geo.draw adds a region: when: when.far keeps it to presses away from the regions already there. A geoLine takes the same form with closed: true.

A region you can reshape

Four seeded rows make one region. Draw another anywhere outside it.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
// One row per vertex. `area` groups the rows into regions.
data: [
{ area: "a", lon: -123.160, lat: 49.280 },
],
schema: {
area: { type: "categorical", domain: ["a"], open: true },
lon: { type: "quantitative", domain: [-123.27, -123.02] },
lat: { type: "quantitative", domain: [49.20, 49.32] },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#46596B", strokeWidth: 0.8 }),
geoPolygon({
stroke: "#EE7B5E", strokeWidth: 2, handleSize: 5,
channels: {
series: { field: "area" },
lon: { field: "lon" },
lat: { field: "lat" },
},
edits: [
edit.geo.move(), // a vertex, by its handle
edit.geo.moveSeries(), // the whole region, by its inside
edit.geo.draw({ when: when.far }), // a new region, away from the others
],
}),
],
});
mount(chart.dom());
Try: Drag a vertex to reshape · drag the inside to move it · drag across open map to draw another.

Geographic rectangles

geoRect boxes are aligned to lon/lat, so they can look slightly curved under Mercator. Drag an edge or corner to reshape a box, drag its body to move it, or click empty space to add another. The zone you press in holds for the whole drag. The cursor shows the zone before you press.

Study areas over the city

edit.geo.brush() resizes and moves; edit.geo.createRect() mints a new box on a click in open space (a click on an existing box grabs it). Pass move: false for resize only, or { edgeInset } to widen the grab band.

const chart = Elicit({
width: 520, height: 360,
margins: { top: 8, right: 8, bottom: 8, left: 8 },
projection: { type: "mercator", domain: vancouver, inset: 6 },
data: [
{ name: "downtown", west: -123.140, south: 49.275, east: -123.100, north: 49.290 },
{ name: "west side", west: -123.185, south: 49.245, east: -123.150, north: 49.262 },
],
schema: {
name: { type: "categorical" },
west: { type: "quantitative", domain: [-123.27, -123.02] },
south: { type: "quantitative", domain: [49.20, 49.32] },
east: { type: "quantitative", domain: [-123.27, -123.02] },
north: { type: "quantitative", domain: [49.20, 49.32] },
},
marks: [
geoBasemap({ geojson: vancouver, fill: "#EDF7F8", stroke: "#6F8294", strokeWidth: 0.7 }),
geoRect({
fill: "rgba(80, 174, 183, 0.18)", stroke: "#37919B", strokeWidth: 1.5,
channels: {
west: { field: "west" },
south: { field: "south" },
east: { field: "east" },
north: { field: "north" },
},
edits: [
edit.geo.brush({ edgeInset: 10 }),
edit.geo.createRect({ width: 0.024, height: 0.014, defaults: { name: "new area" } }),
],
}),
],
});
mount(chart.dom());
Try: Drag a corner or edge to reshape · drag the middle to move · click empty map to add a box.