我正在使用mapbox-android-navigation
和navigation-ui
版本0.11.1来显示我正在创建的路线的转弯。一切都很好,除了我没有从导航UI获得回调。
具体来说,我按照指示在我的NavigationViewOptions对象上设置了监听器。但是听众永远不会被召唤回来。此外,如果您将代码放入NavigationLauncher#startNavigation
以下是我的转码启动代码:
私人乐趣launchTurnByTurn(){
val navigationListener = object: NavigationListener { override fun onNavigationFinished() = Timber.i("onNavigationFinished()") override fun onNavigationRunning() = Timber.i("onNavigationRunning()") override fun onCancelNavigation() = Timber.i("onCancelNavigation()") } val routeListener = object: RouteListener { override fun allowRerouteFrom(offRoutePoint: Point?): Boolean { Timber.i("allowRerouteFrom()") return true } override fun onFailedReroute(errorMessage: String?) = Timber.i("onFailedReroute()") override fun onRerouteAlong(directionsRoute: DirectionsRoute?) = Timber.i("onRerouteAlong()") override fun onOffRoute(offRoutePoint: Point?) = Timber.i("TC onOffRoute") } val simulateRoute = true // Create a NavigationViewOptions object to package everything together val options = NavigationViewOptions.builder() .directionsRoute(routesMap?.currentRoute) .shouldSimulateRoute(simulateRoute) .navigationListener(navigationListener) .routeListener(routeListener) .build() NavigationLauncher.startNavigation(this, options)
}
我的问题是,如果这些听众被调用,或者这个回调功能还没有实现呢?
答案 0 :(得分:0)
您似乎在尝试接受NavigationViewOptions
时将NavigationLauncher.startNavigation
传递到NavigationLauncherOptions
中。
请参见以下说明:https://github.com/mapbox/mapbox-navigation-android/issues/781#issuecomment-374328736