mapbox-navigation-android
mapbox-navigation-android copied to clipboard
Android Drop-In UI: Outdated code/no proper or complete examples
Android API: 32 Mapbox Navigation SDK version: 2.6.0
For example:
Or this:
Currently, we have to use binding.navigationView.api.enableReplaySession() instead of the code above.
Please add an example to use this library with a RouteOptions.
@abhishek1508 please take a look.
Any update? I want to use the Drop-In UI to show a complete turn-by-turn experience without any input from the user. I will be the one providing the origin (the user's current location retrieved by location engine) and the destination/s.
I tried this simple code:
val options =
RouteOptions.builder()
.applyDefaultNavigationOptions()
.applyLanguageAndVoiceUnitOptions(requireContext())
.coordinatesList(coordinates)
.metadata(false)
.build()
binding.navigationView.api.enableTripSession()
binding.navigationView.api.fetchRoutes(options)
binding.navigationView.addListener(object : NavigationViewListener() {
override fun onRouteFetchSuccessful(routes: List<NavigationRoute>) {
binding.navigationView.api.setRoutes(routes)
}
})
But it says:
W/Mapbox: [nav-sdk]: [Store] Cannot dispatch new actions during reducer processing. Action dropped: SetRoutes.
Thank you for sharing the code snippet @VincentJoshuaET
Please take a look at this PR which demonstrates how to request routes outside Drop-In UI and force Drop-In UI to ActiveGuidance state when the route is available.
You might need to add additional dependency
implementation "com.mapbox.navigation:ui-app:2.8.0-alpha.3"
The dependency above is temporary and should be removed with upcoming versions.
I would also recommend to upgrade to v2.8.0-alpha.3
Will this ever be changed so that MapboxNavigationProvider does not need to be referenced anymore and we only use com.mapbox.navigation.dropin.NavigationView?
Will this ever be changed so that
MapboxNavigationProviderdoes not need to be referenced anymore and we only usecom.mapbox.navigation.dropin.NavigationView?
We see value in exposing mapboxNavigation via MapboxNavigationApp and allowing developers to make route requests, register observers etc because these are pretty common use cases. Adding functions like fetchRoutes to NavigationView doesn't serve any additional purpose because these are pure wrappers. Wrappers tend to get outdated and inflexible when it comes to using them.
So to answer your question this not gonna be available via navigationView and with next week's release we are going to remove fetchRoutes from the public API
Is this now the proper way to initiate an active guidance UI with a list of coordinates?
val options =
RouteOptions.builder()
.applyDefaultNavigationOptions()
.applyLanguageAndVoiceUnitOptions(requireContext())
.coordinatesList(coordinates)
.metadata(false)
.build()
MapboxNavigationApp.current()?.requestRoutes(options, object : NavigationRouterCallback {
override fun onCanceled(routeOptions: RouteOptions, routerOrigin: RouterOrigin) {
Timber.d("Canceled requesting routes")
}
override fun onFailure(reasons: List<RouterFailure>, routeOptions: RouteOptions) {
Timber.e("Failure requesting routes. Reasons - %s", reasons.joinToString())
}
override fun onRoutesReady(routes: List<NavigationRoute>, routerOrigin: RouterOrigin) {
binding.navigationView.api.startActiveGuidance(routes)
}
})
Closing this ticket as the OP mentioned was addressed.