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
In order to make batch call, pass an object which will contain the 'key' property, 'batchMode' property set to the correct value (sync, async, or redirect) and batchItems, which will contain an array of objects which represent options for each call. For more information, please refer to batch documentation:
tt.services.<service name>({
batchMode: 'sync'
key: <Your API key>,
batchItems: [{
...
}, {
...
} //... more objects
]
})
.go()
.then(callback);
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());
});
Methods
go( ): Promise
Executes a predefined asynchronous task using the current configuration.
Returns