Skip to main content

Route progress

There might be several cases when you may want to observe a Route Progress to make some additional calculations or handle relevant information about the active route such as ETA, maneuver instructions, remaining waypoints, etc. This is how the route progress may be observed in an Activity:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
Dash.controller.observeRouteProgress()
.collect { /* RouteProgress */ progress ->
// Do something with the RouteProgress
val distance = progress.distanceRemaining
val eta = progress.durationRemaining
}
}
}
}
}
Was this page helpful?