How the SDK works

The SDK is one npm package, @tomtom-org/maps-sdk, with three entry points. Map draws the map, Services calls TomTom's location APIs, and Core holds what both share. Use each alone or together.

Your ApplicationMapLibre GL JSMaps SDK for JavaScriptMapServicesCore

The playground below uses only the Map bundle, with a TomTomMap configured once through Core.

The three bundles

Bundle Import path Runs in Holds Start with
Map @tomtom-org/maps-sdk/map Browser TomTomMap and its modules Map introduction
Services @tomtom-org/maps-sdk/services Browser, Node.js, React Native One async function per TomTom API Services quickstart
Core @tomtom-org/maps-sdk/core Anywhere TomTomConfig, shared types, utilities Core quickstart

Data flow

import { TomTomConfig } from '@tomtom-org/maps-sdk/core';
import { discoverPlaces } from '@tomtom-org/maps-sdk/services';
import { PlacesModule, TomTomMap } from '@tomtom-org/maps-sdk/map';

TomTomConfig.instance.put({ apiKey: 'YOUR_API_KEY', language: 'en-GB' });

const map = new TomTomMap({ mapLibre: { container: 'map', center: [4.9, 52.37], zoom: 13 } });

const places = await PlacesModule.create(map);
await places.show(await discoverPlaces({ query: 'coffee', geoBias: { position: [4.9, 52.37] } }));
  1. TomTomConfig holds the API key and language once, for the map and every service call.
  2. discoverPlaces merges its own parameters over that configuration, calls the API and resolves to a GeoJSON FeatureCollection of Place features.
  3. PlacesModule.show takes that collection as it is and draws it on its own sources and layers.

Map

Services

The same calls run in Node.js, with no map. The Node.js reverse geocoding example runs this one:

import { TomTomConfig } from '@tomtom-org/maps-sdk/core';
import { reverseGeocode } from '@tomtom-org/maps-sdk/services';

TomTomConfig.instance.put({ apiKey: 'YOUR_API_KEY' });

const place = await reverseGeocode({ position: [5.72884, 52.33499] });
console.log(JSON.stringify(place, null, 4));

Core

Next steps