Source: https://developers.woosmap.com/products/mobile/android/distance/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Distance API with Android SDK



You can calculate directions by using the `DistanceService`. This object is an interface to the [Route endpoint of Woosmap Distance API](/products/distance-api/features/route/). This service compute travel distance, time and path for a pair of origin and destination.

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](/products/mobile/android/step-by-step-first-application/) first.

## Building Directions Request

To use distance in the Woosmap Android SDK, instantiate a `DistanceService` and call `distanceService.getRoute()` to initiate a request to the Route endpoint of Woosmap Distance API, passing it at least the origin/destination LatLng.
You can find the full documentation of this endpoint in the [API documentation](https://native-sdk.woosmap.com/android/doc/latest/woosmap-sdk/com.woosmap.sdk.api/-distance-service/get-route.html). 

```kotlin
val distanceService = DistanceService()
val routes = distanceService.getRoute(anOrigin, aDestination, alternatives = true)
```

## Drawing a route

To draw a route you can simply instantiate a `DistanceRenderer` with your map and pass it a route response.

```kotlin
val distanceRenderer = DistanceRenderer(mapView)
distanceRenderer.plotRoutes(routes)
```

* [Android SDK API Reference Documentation](https://native-sdk.woosmap.com/android/doc/latest/)
