Maps SDK for Web

tt.services.calculateRoute

Calculates a route between two locations using the TomTom Routing API;

Parameters need to be passed to the constructor. The method go performs the actual call.

The SDK provides a Promise polyfill for browsers (IE<9) without native ECMAScript 6 support.

The types used in the Routing service:

  • point - longitude, latitude pair (in EPSG4326 projection), with the following constraints:

    • Longitude values must be in the range -180..+180 inclusive.
    • Latitude values must be in the range -90..+90 inclusive.
    • Example: 4.89406, 52.37245
  • circle - A circle with a center point and a radius (in meters).

    • The radius must be a positive integer with the maximum value of 20050000.
    • Note that larger integer values will not be rejected but lowered to the maximum value.
    • Example: circle(4.89406,52.37245,10000)
  • location - A point or a circle.

    • Example: 4.89406,52.37245 circle(4.89406,52.37245,10000)
  • dateTime - A date and time specified in RFC-3339 format with an optional time zone offset.

    • Example: 1996-12-19T16:39:57 1996-12-19T16:39:57-08:00

Constructor

tt.services.calculateRoute([options])

Example
tt.services.calculateRoute({
  key: <Your API key>,
  locations: '4.8,52.3:4.87,52.37'
})
  .go()
  .then(function(routeData) {
    console.log(routeData.toGeoJson());
  });
Parameters
Name Description
options
Object | Array
default:None
Options to be passed to the routing call, or an array of such options objects to perform a batch request.

Methods

go( ): Promise

Executes a predefined asynchronous task using the current configuration.

Returns