Indoor Direction

How to calculate and display the shortest route between indoor 2 locations

  1. Adding an IndoorRenderer
  2. Indoor direction service

This guide will show you different ways to leverage Woosmap Indoor in your Android application.

This guide assume you already know how to add the SDK as a dependency and configure an API Key.
If you never used Woosmap Android SDK before, we strongly recommend to start with the Step by Step Guide first.

This guide also assume you already have an indoor venue prepared in your project.

Adding an IndoorRenderer

To display an Indoor Venue you simply need to instantiate a IndoorRenderer:

kotlin
        val indoorRenderer = IndoorRenderer(mapView, "my_venue", theme = "optional_theme_for_icons") { venue ->
    venue.levels?.forEach { level -> 
        //... 
    } 
} 

    

As you can see the constructor also provides an optional callback once the venue details is loaded, the primary usage for it is to set up your own customized level selector. You can add a level changed listener using addOnLevelChanged() and tell the renderer to change the currently displayed level using the currentLevel property. The default level selector can be simply disabled with:

kotlin
        mapView.setUiSettings {
    isLevelSelectorEnabled = false
}

    

Indoor direction service

Woosmap Indoor API provides you tools to create an optimized navigation experience:

Use the IndoorService class to calculate the shortest route between 2 locations (IndoorService().directions()) and display the route on the map thanks to the plotRoute() method of the IndoorRenderer.

8 parameters are available to provide a suitable navigation experience to your user:

Field Type Mandatory Default Description
venueId String X   Id of the Venue
origin String X   A string with the format lat,lng,level or poi_id (identifier of a POI) or ref:poi_ref (ref of a poi with starting with ‘ref:’)
destination String X   A string with the format lat,lng,level or poi_id (identifier of a poi) or ref:poi_ref (ref of a poi with starting with ‘ref:’)
language String   en Language for instructions
units String   metric Distance value unit
mode String   null Routing profile for using suitable path only
avoid String   null Exclude one/multiple zone from the walkbale network of the venue, expected zone format level;lat,lng;lat,lng; ... ;lat,lng
waypoints String   null A list of points by which the route should pass. Ex: lat,lng,level|poi_id|lat,lng,level|ref:poi_ref
optimize Boolean   false You may set it to true with the waypoints parameter. This way the provided route is optimized by rearranging the waypoints in a more efficient order

Here is a code sample:

On a background thread:

kotlin
        const indoorService = new window.woosmap.map.IndoorService();
val indoorService = IndoorService()
val directionResponse = indoorService.directions(
    venue_id = "my_venue",
    origin = "${x.latitude},${x.longitude},0",
    destination = "${y.latitude},${y.longitude},0",
    language = "en",
    units = "metric",
    mode = "wheelchair"
)

    

then on the UI thread:

kotlin
        indoorService.plotRoute(directionResponse.routes[0])

    

Woosmap Demo Screenshot

Was this article helpful?
Have more questions? Submit a request