Display toll roads and ferries on your journey overview
This example will explain how to add ferries and toll roads to the journey overview in order to better inform users about what to expect.
View on Github
- Chargetrip API key - to plot routes outside this region
- Mapbox API key - to display the map
- URQL - a lightweight graphQL client
- Plotting a route starts with executing the newRoute mutation. This mutation requires information about the car, origin and destination. After the mutation is finished executing a route id will be returned.
- Ferry steps are not split up by default. Inside interface.js it is first necessary to see if a leg contains a ferry route, and if so, to then split up the leg so as to more easily display it as a step on the journey overview.
- It is also useful to check if the leg contains toll roads before rendering the entire journey overview, which has now been split into separate legs.
The last couple of examples explained most of the variables when it comes to routing. In the next step, the vector tile service is introduced.