使用 0.4.0-SNAPSHOT 时未触发 Mapbox 导航`onProgressChange()`
Mapbox Navigation `onProgressChange()` not fired when 0.4.0-SNAPSHOT used
我已经实现了 Mapbox 导航,最近它开始工作了,现在我想将导航从 0.3.1
更新到 0.4.0-SNAPSHOT
,不幸的是更新后 onProgressChange()
没有被解雇,即使我尚未对代码进行任何更改。
NOTE: onLocationChanged
works in both cases.
编辑
NOTE: 0.3.1
still fires onProgressChange()
although its speed is 0.0
, but not 0.4.0-SNAPSHOT
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 或更小,则不会调用 onProgressChange
。如果这不是问题所在,任何其他信息和代码片段都将有助于解决此问题。
我已经实现了 Mapbox 导航,最近它开始工作了,现在我想将导航从 0.3.1
更新到 0.4.0-SNAPSHOT
,不幸的是更新后 onProgressChange()
没有被解雇,即使我尚未对代码进行任何更改。
NOTE:
onLocationChanged
works in both cases.
编辑
NOTE:
0.3.1
still firesonProgressChange()
although its speed is0.0
, but not0.4.0-SNAPSHOT
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 或更小,则不会调用 onProgressChange
。如果这不是问题所在,任何其他信息和代码片段都将有助于解决此问题。