Routing service NodeJS

Server-side routing service with NodeJS implementation

CodeSandbox is a third-party service and may use cookies to see your IP address and browser info. Cookie notice

View on GitHub
import { TomTomConfig } from '@tomtom-org/maps-sdk/core';
import { calculateRoute } from '@tomtom-org/maps-sdk/services';
import { API_KEY } from './config';

TomTomConfig.instance.put({ apiKey: API_KEY });

(async () => {
    const response = await calculateRoute({
        locations: [
            [4.89066, 52.37317],
            [4.47059, 51.92291],
        ],
    });
    console.log(JSON.stringify(response.features[0].properties, null, 4));
})();

SDK 1.0.0-rc.7

Two coordinates go in, and the first route’s properties print from a plain Node process.

  • calculateRoute takes the stops as a locations array and returns routes as GeoJSON features that hold geometry and travel metadata in one object.
  • Each feature’s properties holds the route’s own summary, so nothing else is called to describe the line that came back.
  • The same call runs unchanged in the browser, so a server and its client agree on one route shape.

Related examples