Directions Service
iOS V4
The class MPDirectionsService
is used to request routes from one point to another. The minimal required input is an origin
and a destination
. You need to build a query using the MPDirectionsQuery
class.
This example shows how to setup and execute a query for a route:
The route can be customized via the directionsRenderer
. An example could be the color of the rendered path and the background color of the rendered line. This can be set like this:
Change Transportation Mode
In MapsIndoors, the transportation mode is referred to as travel mode. There are five travel modes, walking, bicycling, driving, transit (public transportation) and unknown. The travel modes generally applies for outdoor navigation. Indoor navigation calculations are based on walking travel mode.
Set travel mode on your request using the travelMode
property on MPDirectionsQuery
:
The travel modes generally applies for outdoor navigation. Indoor navigation calculations are based on walking travel mode.
Route Restrictions
There are several ways to influence the calculated route by applying various restrictions to the directions query:
Avoid and/or exclude certain way types under certain circumstances
Apply restrictions based on User Roles
Avoid and exclude way types
It is possible to avoid and/or exclude certain way types when calculating a route. Avoiding a way type means that DirectionsService
will do its best to find a route without the avoided way types, but if no route can be found without them, it will try to find a route where the avoided way types may be used. To eliminate certain way types entirely, add them as excluded way types. If a way type is both avoided and excluded, excluded will be obeyed.
It may for example be desirable to provide a route better suited for users with physical disabilities by avoiding e.g. stairs. This can be achieved by avoiding that way type on the route using the avoidWayTypes
property:
In an emergency situation it may be required to not use elevators at all. This can be achieved by adding the way type elevator to the excludeWayTypes
property:
App User Role Restrictions
In the MapsIndoors CMS it is possible to restrict certain ways in the route network to be used by users of certain user roles.
It is possible to get the available user roles with help of the MPSolutionProvider
:
User roles can be set on a global level using MapsIndoors.shared.userRoles
.
Setting the user roles globally will effect all services that uses user roles. The MPDirectionsService
will also use the user roles.
Transit Departure and Arrival Time
Set a departure date or an arrival date on the route using the departure
or arrival
property. This is relevant when using the Transit travel mode. It will only make sense to set one of these properties at a time.
Last updated