Mapbox Navigation `offRoute()` 在第一个 `step` 完成时调用
Mapbox Navigation `offRoute()` called when first `step` finishes
因此,我使用的是版本 Mapbox Navigation 0.3.1
,我正在从私有 OSRM 服务器获取路线。 Snap-to-route
和其他功能工作正常,但是当第一步完成时导航不会继续下一步并且正在调用 offRoute
方法。我被困在这里大约 1-2 个月。我将不胜感激任何帮助。
Below, my code snippet of Mapbox Navigation implementation.
public class MapActivity implements MapboxMap.OnMarkerClickListener
,OnMapReadyCallback, AlertLevelChangeListener, ProgressChangeListener, OffRouteListener
,NavigationEventListener, LocationEngineListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fabStartNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// star Navigation
startNavigation();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// Remove all navigation listeners being used
mNavigation.removeNavigationEventListener(this);
mNavigation.removeAlertLevelChangeListener(this);
mNavigation.removeProgressChangeListener(this);
mNavigation.removeOffRouteListener(this);
// End the navigation session
mNavigation.endNavigation();
mapView.onDestroy();
}
//navigation controller
private void startNavigation(){
mNavigation.addNavigationEventListener(this);
mNavigation.addAlertLevelChangeListener(this);
mNavigation.addOffRouteListener(this);
mNavigation.addProgressChangeListener(this);
mNavigation.setSnapToRoute(true);
/*LocationEngine mLocationEngine = LostLocationEngine.getLocationEngine(this);
// mNavigation.setLocationEngine(mLocationEngine);*/
mLocationEngine = LostLocationEngine.getLocationEngine(this);
mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
mLocationEngine.addLocationEngineListener(this);
mLocationEngine.activate();
mNavigation.startNavigation(mPlannedRoute);
}
// navigation listeners
@Override
public void onAlertLevelChange(int alertLevel, RouteProgress routeProgress) {
switch (alertLevel) {
case HIGH_ALERT_LEVEL:
break;
case MEDIUM_ALERT_LEVEL:
break;
case LOW_ALERT_LEVEL:
break;
case ARRIVE_ALERT_LEVEL:
break;
case NONE_ALERT_LEVEL:
break;
case DEPART_ALERT_LEVEL:
break;
}
}
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
}
@Override
public void userOffRoute(Location location) {
}
@Override
public void onRunning(boolean running) {
}
@Override
public void onConnected() {
mNavigation.setLocationEngine(mLocationEngine);
mLocationEngine.requestLocationUpdates();
}
@Override
public void onLocationChanged(Location location) {
}
}
这听起来像是您的 运行 进入了一个非常古老的错误,此错误已被修复。我的建议是升级到 0.4.0 或 0.5.0-snapshot。
因此,我使用的是版本 Mapbox Navigation 0.3.1
,我正在从私有 OSRM 服务器获取路线。 Snap-to-route
和其他功能工作正常,但是当第一步完成时导航不会继续下一步并且正在调用 offRoute
方法。我被困在这里大约 1-2 个月。我将不胜感激任何帮助。
Below, my code snippet of Mapbox Navigation implementation.
public class MapActivity implements MapboxMap.OnMarkerClickListener
,OnMapReadyCallback, AlertLevelChangeListener, ProgressChangeListener, OffRouteListener
,NavigationEventListener, LocationEngineListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fabStartNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// star Navigation
startNavigation();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// Remove all navigation listeners being used
mNavigation.removeNavigationEventListener(this);
mNavigation.removeAlertLevelChangeListener(this);
mNavigation.removeProgressChangeListener(this);
mNavigation.removeOffRouteListener(this);
// End the navigation session
mNavigation.endNavigation();
mapView.onDestroy();
}
//navigation controller
private void startNavigation(){
mNavigation.addNavigationEventListener(this);
mNavigation.addAlertLevelChangeListener(this);
mNavigation.addOffRouteListener(this);
mNavigation.addProgressChangeListener(this);
mNavigation.setSnapToRoute(true);
/*LocationEngine mLocationEngine = LostLocationEngine.getLocationEngine(this);
// mNavigation.setLocationEngine(mLocationEngine);*/
mLocationEngine = LostLocationEngine.getLocationEngine(this);
mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
mLocationEngine.addLocationEngineListener(this);
mLocationEngine.activate();
mNavigation.startNavigation(mPlannedRoute);
}
// navigation listeners
@Override
public void onAlertLevelChange(int alertLevel, RouteProgress routeProgress) {
switch (alertLevel) {
case HIGH_ALERT_LEVEL:
break;
case MEDIUM_ALERT_LEVEL:
break;
case LOW_ALERT_LEVEL:
break;
case ARRIVE_ALERT_LEVEL:
break;
case NONE_ALERT_LEVEL:
break;
case DEPART_ALERT_LEVEL:
break;
}
}
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
}
@Override
public void userOffRoute(Location location) {
}
@Override
public void onRunning(boolean running) {
}
@Override
public void onConnected() {
mNavigation.setLocationEngine(mLocationEngine);
mLocationEngine.requestLocationUpdates();
}
@Override
public void onLocationChanged(Location location) {
}
}
这听起来像是您的 运行 进入了一个非常古老的错误,此错误已被修复。我的建议是升级到 0.4.0 或 0.5.0-snapshot。