Maps SDK for Web

tt.services.matrixRouting

Matrix Routing service implementation using using the TomTom Routing API - Matrix Routing.

The Routing API Matrix Routing service allows the calculation of a matrix of route summaries for a set of routes which are defined with origin and destination locations.

For every given origin this service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table, and each cell in the table contains the costs of routing from the origin to the destination for that cell.

The following costs are computed for each route:

  • Travel times
  • Distances

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

If you want to explicitly decide which batch mode you want to use, add a property 'batchMode' with its value set to one of the properties: sync, async, or redirect.

For more information, please refer to the Matrix Routing documentation here.

Constructor

tt.services.matrixRouting([options])

Example
var origins = [
  { point: { latitude: 51.63685, longitude: 19.4171 } },
  { point: { latitude: 51.63685, longitude: 19 } }
];
var destinations = [
  { point: { latitude: 52.23498, longitude: 21.00849 } },
  { point: { latitude: 52.63685, longitude: 18 } }
];
function callbackFn(routeGeoJson) {
  console.log(routeGeoJson);
}
tt.services.matrixRouting({
  key: <Your API key>,
  origins: origins,
  destinations: destinations,
  traffic: true
})
.go()
.then(callbackFn);
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.
options.arriveAt
String
default:None

The properly formatted date with a time value. Date cannot be in the past and has to follow ISO 8601 standard.


A setter and getter for the 'arriveAt' attribute. The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt.
options.avoid
Array | String
default:None

Specifies something that the route calculation should try to avoid when determining the route.


A setter and getter for the avoid attribute. Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times. Possible values:
  • tollRoads avoids toll roads.
  • motorways avoids motorways.
  • ferries avoids ferries.
  • unpavedRoads avoids unpaved roads.
  • carpools avoids routes that require use of carpool (HOV/ High Occupancy Vehicle) lanes.
  • alreadyUsedRoads avoids using the same road multiple times.
Most useful in conjunction with routeType=thrilling.
options.batchMode
String
default:None

Possible values: sync, async, redirect


This option lets you manually set how a matrix request should be performed. Otherwise we decide for you if you should use sync, async, or redirect mode. For a further explanation please refer to the Matrix Routing docs here.
options.computeTravelTimeFor
String
default:None

Setting 'all' provides additional information regarding travel times.


A setter and getter for the 'computeTravelTimeFor' attribute. Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time. Possible values:
  • none - do not compute additional travel times.
  • all - compute travel times for all types of traffic information. Specifies all results in the fields noTrafficTravelTimeInSeconds, historicTrafficTravelTimeInSeconds and liveTrafficIncidentsTravelTimeInSeconds being included in the summaries in the route response.
options.departAt
String
default:None

The properly formatted date with the time or 'now' value. Date cannot be in the past and has to follow ISO 8601 standard.


A setter and getter for the 'departAt' attribute. The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future. The departAt parameter cannot be used in conjunction with arriveAt.
options.destinations
Array
default:None

A set of destination locations represented by points (latitude/longitude object).


A setter and getter for the 'destinations' attribute. A set of destination locations represented by points (latitude/longitude object). At least one destination is required.
options.hilliness
String
default:None

The level of hilliness on a thrilling route.


A setter and getter for the 'hilliness' attribute. The degree of hilliness for thrilling route. Possible values: low, normal, high. This parameter can only be used in conjunction with routeType thrilling.
options.key
String
default:None

A valid API Key for the requested service.


A valid API Key is required to make use of the given service. It can be issued in the Developer Portal.
options.origins
Array
default:None

A set of origin locations represented by points (latitude/longitude object).


A setter and getter for the 'origins' attribute. A set of origin locations represented by points (latitude/longitude object). At least one origin is required.
options.routeType
String
default:None

The route type to be used during route calculation.


A setter and getter for the routeType attribute. Represents the type of route requested. Notes on specific values:
  • fastest returns the fastest route.
  • shortest returns the shortest route by distance.
  • eco routes balance economy and speed.
  • thrilling routes include interesting or challenging roads and use as few motorways as possible. You can choose the level of turns included and also the degree of hilliness. See the hilliness and windingness parameters to set this. There is a limit of 900km on routes planned with routeType=thrilling The default value is fastest.
options.traffic
String | Boolean
default:None

A boolean flag to determine if traffic data should be used to calculate the route.


A setter and getter for the 'traffic' attribute. Possible values: true (do consider all available traffic information during routing). false (ignore current traffic data during routing). Note that although the current traffic data is ignored during routing, the effect of historic traffic on effective road speeds is still incorporated. The default is true.
options.travelMode
String
default:None

The primary means of transportation to be used while routing.


A setter and getter for the 'travelMode' attribute. The mode of travel for the requested route. Possible values: car, truck, taxi, bus, van, motorcycle, bicycle, pedestrian. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the element of the response for that section will be 'other'.
options.vehicleAxleWeight
Number
default:None

The vehicle axle wight in kg.


A setter and getter for 'vehicleAxleWeight' attribute. Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered during route planning. This parameter is currently only considered for travelMode truck.
options.vehicleCommercial
Boolean
default:None

True if the vehicle is used for commercial purposes.


A setter and getter for the 'vehicleCommercial' attribute. Vehicle is used for commercial purposes and thus may not be allowed to drive on some roads. This parameter is currently only considered for travelMode truck.
options.vehicleEngineType
String
default:None

The vehicle engine type.


A setter and getter for 'vehicleEngineType' attribute. Engine type of the vehicle. This parameter is currently only considered for travelMode truck. Valid options are: combustion, electric.
options.vehicleHeight
Number
default:None

The vehicle height in meters.


A setter and getter for the 'vehicleHeight' attribute. Height of the vehicle in meters. A value of 0 means that height restrictions are not considered during route planning. This parameter is currently only considered for travelMode truck.
options.vehicleLength
Number
default:None

The vehicle length in meters.


A setter and getter for the 'vehicleLength' attribute. Length of the vehicle in meters. A value of 0 means that length restrictions are not considered during route planning. This parameter is currently only considered for travelMode truck.
options.vehicleLoadType
Array | String
default:None

The array of truck cargo classifications.


A setter and getter for the 'vehicleLoadType' attribute. Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Use these for routing in US
  • USHazmatClass1 Explosives
  • USHazmatClass2 Compressed gas
  • USHazmatClass3 Flammable liquids
  • USHazmatClass4 Flammable solids
  • USHazmatClass5 Oxidizers
  • USHazmatClass6 Poisons
  • USHazmatClass7 Radioactive
  • USHazmatclass8 Corrosives
  • USHazmatClass9 Miscellaneous
Use these for routing in all other countries
  • otherHazmatExplosive Explosives
  • otherHazmatGeneral Miscellaneous
  • otherHazmatHarmfulToWater Harmful to water
This parameter is currently only considered for travelMode truck.
options.vehicleMaxSpeed
Number
default:None

The maximal allowed vehicle speed in km/h (kilometers per hour).


A setter and getter for the 'vehicleMaxSpeed' attribute. Maximum speed of the vehicle in km/hour. A value of 0 means that an appropriate value for the vehicle will be determined and applied during route planning. A non-zero value may be overridden during route planning. This parameter is currently only considered for travelMode truck.
options.vehicleWeight
Number
default:None

The vehicle weight in kg (kilograms).


A setter and getter for 'vehicleWeight' attribute. Weight of the vehicle in kg. A value of 0 means that weight restrictions are not considered during route planning. This parameter is currently only considered for travelMode truck.
options.vehicleWidth
Number
default:None

The vehicle width in meters.


A setter and getter for the 'vehicleWidth' attribute. Width of the vehicle in meters. A value of 0 means that width restrictions are not considered during route planning. This parameter is currently only considered for travelMode truck.
options.windingness
String
default:None

The level of windingness on a thrilling route.


A setter and getter for the 'windingness' attribute. The level of turns for thrilling route. Possible values: low, normal, high. This parameter can only be used in conjunction with routeType thrilling.

Methods

go( ): Promise

Executes a predefined asynchronous task using the current configuration.

Returns