-
Notifications
You must be signed in to change notification settings - Fork 321
Closed
Description
Hey, I implemented the custom NavigationActivity following part of the example in the Mapbox documentation and can show the navigation UI as map so far but can't start the navigation itself nor show the user’s location. The same problem exists when implementing it via a NavigationFragment. How can I pass the missing information when I call my NavigationActivity/NavigationFragment from my MainActivity and start the navigation correctly? Thanks a lot for any help!
I create the directionsRoute and call navigationView.startNavigation(options) with NavigationViewOptions.builder() like this:
fun onNavigationReady(isRunning: Boolean) {
...
calculateRoute(origin, destination)
}
private fun calculateRoute(origin: Point , destination: Point) {
NavigationRoute.builder(this.context)
.accessToken(Mapbox.getAccessToken()!!)
.origin(origin)
.destination(destination)
.build()
.getRoute( object : Callback<DirectionsResponse> {
// Send request to Direction API
override fun onFailure(call: Call<DirectionsResponse>? , t: Throwable?) {
}
override fun onResponse(call: Call<DirectionsResponse>? ,
response: Response<DirectionsResponse>?) {
if (response?.body() == null || response.body()?.routes()?.size!! < 1) {
return
}
directionsRoute = response.body()!!.routes()[0]
startNavigation()
}
})
}
private fun startNavigation() {
if (directionsRoute == null) return
val options = NavigationViewOptions.builder()
.directionsRoute(directionsRoute)
.shouldSimulateRoute(true)
.navigationListener(this)
.build()
navigationView.startNavigation(options)
}
Metadata
Metadata
Assignees
Labels
No labels