Maps & Geographic Data

<GraphCanvas> can render your graph on a tiled basemap — a flat 2D map or a 3D globe — and pin nodes to real-world coordinates. You opt in with two props:

  • map — true, or a MapConfig object (tile provider, zoom range, …).
  • is3D — true mounts a globe (GlobeLayer); false mounts a flat planar map (FlatLayer).
import { GraphCanvas } from '@kineviz/gl';

<GraphCanvas
  container={el}
  apiRef={apiRef}
  is3D                       // 3D globe (omit / false → flat map)
  nodeCloud
  edgeCloud
  map={{ tileProvider: 'cartoDarkNoLabels' }}
/>

You still load your own data (api.nodes.add / api.edges.add) — the map only provides the basemap + geo-pinning.

Placing nodes by latitude / longitude

When the map prop is set, the built-in geoLayout auto-pins every node that has coordinate properties. It looks for lat / latitude and lng / lon / long / longitude (case-insensitive), so this just works:

await api.nodes.add([
  { id: 'LHR', properties: { name: 'London',   lat: 51.47, lng:  -0.45 } },
  { id: 'JFK', properties: { name: 'New York', lat: 40.64, lng: -73.78 } },
]);
// nodes are pinned onto the map automatically — no extra call needed

To use differently-named properties, pin explicitly with positionNodesByGeo:

await api.map.positionNodesByGeo({ latProperty: 'y', lngProperty: 'x' });

World units are scene-space, not raw degrees — always go through the map (geoLayout / positionNodesByGeo), never layout.setPositions({x:lng,y:lat}).

Tile providers

Pass a built-in provider by name via map.tileProvider. All of these are free and need no API key:

Name Look Network
vectorDark Flat-shaded vector earth (countries + graticule) Offline — bundled in the engine
cartoDarkNoLabels Dark raster, no labels (good default for globes) Carto CDN
cartoDark / cartoLight / cartoVoyager Carto raster basemaps Carto CDN
cartoDarkNoLabelsRetina Dark @2x HD raster Carto CDN
googleSatellite / googleHybrid / googleTerrain / googleRoads Google imagery / maps Google
esriWorldImagery / esriWorldTopo ESRI satellite / topo ArcGIS
stamenToner / stamenWatercolor / stadiaAlidadeDark Stylised Stadia/Stamen
openStreetMap OSM street map OSM
map={{ tileProvider: 'googleSatellite' }}   // blue-marble satellite globe
map={{ tileProvider: 'cartoDarkNoLabels' }} // clean dark raster

Providers that require a key are functions you call with the token:

import { MapTileProviders } from '@kineviz/gl';
map={{ tileUrl: MapTileProviders.mapboxDark('pk.your_token') }}

Offline vector basemap (vectorDark)

vectorDark renders the basemap from a world outline bundled inside the engine — country polygons + a graticule drawn per tile, with no network request. The same low-detail outline renders at every zoom, so it stays a crisp flat-shaded earth; pair it with a low maxLevel so deep zoom keeps the vector look instead of generating endless tiles.

map={{ tileProvider: 'vectorDark', maxLevel: 4 }}

For custom colours, build your own with createVectorTileProvider:

import { createVectorTileProvider } from '@kineviz/gl';

const tileUrl = createVectorTileProvider({
  ocean: '#0b1a2e',     // background fill
  land:  '#1c3147',     // country fill
  border: '#315a80',    // country outline ('' to omit)
  grid:  '#1a3a55',     // graticule ('' to omit)
  gridStepDeg: 15,      // graticule spacing; 0 disables the grid
});

<GraphCanvas is3D map={{ tileUrl, maxLevel: 4 }} … />

Because it needs no tile server, vectorDark is the right default for offline / air-gapped deployments and for the dark "data globe" aesthetic.

Custom tile provider

map.tileUrl is any (x, y, level) => string. Return a normal tile URL, or a data: URL you render yourself (that is exactly how vectorDark works):

map={{ tileUrl: (x, y, z) => `https://tiles.example.com/${z}/${x}/${y}.png` }}

MapConfig reference

Field Default Notes
tileProvider — Built-in provider name. Wins over tileUrl.
tileUrl — Custom (x,y,level) => url function.
minLevel / maxLevel 0 / 18 Tile zoom range. Cap maxLevel for vector / to limit tile count.
autoFit true Frame the data on mount. Set false if you drive the camera yourself.
mapSize 10 Planar map size in scene units (is3D=false).
globeRadius 5 Globe radius in scene units (is3D=true).
visible true Toggle the basemap without unmounting.

map={true} is shorthand for the default config.

Globe extras

On a 3D globe, edges between geo-pinned nodes automatically ride great-circle arcs. To fly icons/markers along those arcs (flights, attacks, packets), add a MarkerLayer — it travels the same arc and can dim with the edges on focus. See the Live flights and Cyber threat map examples.

Performance

  • Prefer cartoDarkNoLabels or vectorDark over @2x retina providers for globes — retina quadruples per-tile bytes and makes zoom-time level swaps pop. The engine fades each new tile in to smooth the transition.
  • Cap maxLevel when you don't need street-level detail — it bounds how many tiles load (and, for vectorDark, how many tiles are rendered).
  • For a stable basemap, memoize the map config object — an inline map={{…}} is a new object every render and churns the map layer:
const mapConfig = useMemo(() => ({ tileProvider: 'vectorDark', maxLevel: 4 }), []);
<GraphCanvas is3D map={mapConfig} … />

See also