2017-07-16 53 views
0

我實現Mapbox導航和最近得到了它的工作,現在我想更新導航從0.3.10.4.0-SNAPSHOT,不幸的是更新後onProgressChange()沒有被解僱,甚至不`解僱儘管我沒有對代碼做任何修改。Mapbox導航`onProgressChange()時0.4.0-SNAPSHOT使用

注意:onLocationChanged適用於這兩種情況。

編輯

注:0.3.1仍是起火onProgressChange()雖然它的速度是0.0,但不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) { 

    } 
} 

回答

1

難道您收到的位置更新有沒有速度值?如果速度值爲0或更小,則不會調用onProgressChange。如果這不是問題,任何其他信息和代碼片段將有助於解決這個問題。