Directions Service
Last updated
Last updated
Ready to add indoor navigation to your app with MapsIndoors SDK?
This guide will show you how to implement directions, render routes, and interact with them in your application.
Design
Would you like to show textual directions in a UI?
What will your user interface look like?
What will the user experience be like
Would you like to show directions on the map?
How will the end user let the map know it's time to update with the next part of their journey?
From an implementation standpoint, there are two functional things that need to be taken care of.
Setting up and requesting directions
The first step in getting directions is initializaing the directions service instance. By passing the externalDirectionsProvider, the MapsIndoors SDK will handle merging responses from the base map, e.g. outdoor directions that will charge billable requests if you request from somewhere else other than MapsIndoors data (e.g. an end users house, to somewhere indoors.)
The class DirectionsService
is used to request routes from one point to another. The minimal required input is an origin
and a destination
.
Mapbox (required parameter of the DirectionsService instance)
Google (not required for legacy reasons, but recommended to pass an externalDirectionsProvider as a parameter)
In the below example, the coordinates are hard coded, but you'll likely want to retrieve them from location objects. It's recommended to get those from the anchor points, e.g.
In MapsIndoors, the transportation mode is referred to as travel mode. There are four travel modes, walking, bicycling, driving and transit (public transportation). The travel modes generally apply to outdoor navigation. Indoor navigation calculations are based on walking travel mode.
Set travel mode on your request using the travelMode
property on routeParameters
:
Relevant for outdoor directions only
DRIVING
BYCYCLING
WALKING
TRANSIT (Only supported with Google Maps as the external provider)
For a wheelchair user or a user with physical disabilities it could be relevant to request a Route that avoids stairs, escalators and steps.
Set avoid stairs on your request using the avoidStairs
property on routeParameters
:
Application User Roles is a feature that lets you define various roles, you can assign to your users. In the context of route calculation, the feature is used to differentiate routing from one user type to the another. In the MapsIndoors CMS it is possible to restrict paths and doors in the route network for certain User Roles.
You can get available Roles for your MapsIndoors Solution with the help of the SolutionsService:
For more information, see the getUserRoles documentation which returns User Role objects.
User Roles can be set on a global level using mapsindoors.MapsIndoors.setUserRoles()
.
For more information, see the setUserRoles method in our documentation.
This will affect all following Directions requests, visibility of Locations as well as search queries with LocationsService
. Be mindful of what restrictions are set on locations if your solution is to utilize user roles within MapsIndoors.
Set a departure date or an arrival date on the route using the transitOptions
property. It will only make sense to set one of these properties at a time.
This parameter is only implemented on our side with Google Maps, not Mapbox.
For more information about available options on the
transitOption
object, see google.com/maps/documentation.
Additional reading
For more information on the options you can provide, check the documentation on getting routes.