Quickstart
The Routing SDK provides the tools to integrate the TomTom Routing API into an iOS application. It is used to calculate a route between an origin and a destination, using a range of options and taking traffic into account. Read more about TomTom’s Routing parameters.
Project set up
To use the Routing SDK, you will need to do the following:
- Get your TomTom API key from the Developer Portal. You can find instructions on how to do this at the How do I get a TomTom API Key? page.
- Set up the project - Project set up guide.
- Add the
Routing
and theOnline Routing
module dependencies in thePodfile
and install them by executing thepod install
command.1TOMTOM_SDK_VERSION = '0.2.3404'23target 'YourAppTarget' do4 use_frameworks!5 pod 'TomTomSDKRoutePlannerOnline', TOMTOM_SDK_VERSION6 pod 'TomTomSDKRoutePlanner', TOMTOM_SDK_VERSION7end - Once the project is set up and both routing modules are added to your target, import the following frameworks:
import TomTomSDKRoutePlannerOnline
Routing SDK entry point
After all the preparations above, you can initialize the OnlineRoutePlanner
object. It is the entry point for performing routing requests.
1init() {2 self.routePlanner = OnlineRoutePlanner(apiKey: "<ROUTING-KEY>")3}
You must set the API key before initializing OnlineRoutePlanner
:
.
Routing basic usage
The OnlineRouting module can be used to obtain a route between two points. This module has to be used together with the Routing module.
To calculate a route from A to B, you need to provide route planning criteria. They are built using the RoutePlanningOptions
class. Once you have a RoutePlanningOptions
object, pass it to the planRoute
method from the OnlineRoutePlanner
object in order to get the result. Read more about routing options and route planning in the Planning a route guide.
For a more advanced navigation experience, you can add optional intermediate locations to the route. Read more about this feature in the Waypoints and custom routes guide.
There are two options for planning a route:
- slower
planRoute
(complete
) - faster
planRoute
(firstIncrement
)
The faster method delivers only the first guidance increment. This guidance increment contains one or more potentially combinable instructions and the corresponding lane guidance.