我正在使用mapbox-android-navigation
andnavigation-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)
}
我的问题是,应该调用这些侦听器,还是这个回调功能还没有实现?