Skip to main content

Android

Setup

Add Retrofit (or OkHttp) to your build.gradle:

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

API Service

interface ArohonApi {
@GET("v1/route")
suspend fun getRoute(
@Query("origin") origin: String,
@Query("destination") destination: String,
@Query("vehicle_type") vehicleType: String = "car",
@Header("Authorization") auth: String = "Bearer $API_KEY"
): RouteResponse
}

data class RouteResponse(
val distance: Double,
val duration: Int,
val polyline: String,
val steps: List<Step>
)

Usage

val retrofit = Retrofit.Builder()
.baseUrl("https://map.arohon.co/")
.addConverterFactory(GsonConverterFactory.create())
.build()

val api = retrofit.create(ArohonApi::class.java)
val route = api.getRoute("23.81,90.41", "23.75,90.37")

Map Display

Use MapLibre Android with a custom tile source that adds the Authorization header.