我想在Mapbox SDK的帮助下实现逐行导航应用程序。 如果我使用他们的navigationView,它不是真正可自定义的,则只能设置颜色。 我尝试将MapView与MapBoxNavigation一起使用,但是在更改进度后,路线显示没有刷新。
private void startNavigation(DirectionsRoute route) {
if (locationComponent != null) {
navigation = new MapboxNavigation(this, getString(R.string.access_token));
navigation.addProgressChangeListener(new ProgressChangeListener() {
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
//Toast.makeText(MainActivity.this, "progress: " + routeProgress.distanceTraveled(), Toast.LENGTH_SHORT).show();
}
});
navigation.addMilestoneEventListener(new MilestoneEventListener() {
@Override
public void onMilestoneEvent(RouteProgress routeProgress, String instruction, Milestone milestone) {
//Toast.makeText(MainActivity.this, "instruction: " + instruction, Toast.LENGTH_SHORT).show();
}
});
LocationEngine locationEngine = LocationEngineProvider.getBestLocationEngine(this);
navigation.setLocationEngine(locationEngine);
navigationMapRoute.addProgressChangeListener(navigation);
navigationMapRoute.addRoute(route);
navigation.startNavigation(route);
camera = new NavigationCamera(mapboxMap, navigation, locationComponent);
camera.start(route);
}
}