2016-11-18 7 views
0

開始点と終了点には2つのAutoCompleteTextViewがあります。Skobbler Mapで2点(始点と終点)を結ぶ線を設定します。Android

currentText.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
       currentText.setText(startingPointSearchAdapter.getPlaceList().get(i).getName()); 
       Place startPointPlace = startingPointSearchAdapter.getPlaceList().get(i); 
       if (mapView != null) { 
        CustomSKAnnotation skAnnotation = new CustomSKAnnotation(new Random().nextInt(),startPointPlace.getName()); 
        skAnnotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_BLUE); 
        skAnnotation.setLocation(new SKCoordinate(startPointPlace.getLongitude(), startPointPlace.getLatitude())); 
        mapView.addAnnotation(skAnnotation, SKAnimationSettings.ANIMATION_PIN_DROP); 
        mapView.deleteAllAnnotationsAndCustomPOIs(); 
       } 
      } 
     }); 

を、エンドポイントのために、私が使用します:onCreate()方法では、開始点のために、私が使用ここで

private void showRoute() { 
    SKRouteSettings route = new SKRouteSettings(); 
    route.setStartCoordinate(new SKCoordinate()); 
    route.setDestinationCoordinate(new SKCoordinate()); 
    route.setNoOfRoutes(1); 
    route.setRouteMode(SKRouteSettings.SKRouteMode.CAR_FASTEST); 
    route.setRouteExposed(true); 
    SKRouteManager.getInstance().setRouteListener(this); 
    SKRouteManager.getInstance().calculateRoute(route); 
} 

destinationText.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     @Override 
     public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
      destinationText.setText(destinationPointSearchAdapter.getPlaceList().get(i).getName()); 
      Place destinationPointPlace = destinationPointSearchAdapter.getPlaceList().get(i); 
      if (mapView != null) { 
       CustomSKAnnotation skAnnotation = new CustomSKAnnotation(new Random().nextInt(),destinationPointPlace.getName()); 
       skAnnotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_RED); 
       skAnnotation.setLocation(new SKCoordinate(destinationPointPlace.getLongitude(), destinationPointPlace.getLatitude())); 
       mapView.addAnnotation(skAnnotation, SKAnimationSettings.ANIMATION_PIN_DROP); 
       mapView.deleteAllAnnotationsAndCustomPOIs(); 
      } 
     } 
    }); 

私は2つの点の間routeするための方法を持っています、 route.setStartCoordinate(new SKCoordinate()); route.setDestinationCoordinate(new SKCoordinate());

私はルートを描画するように、開始点の座標と目的地の座標を設定する?

答えて

2

私は右の質問を理解していればあなただけ実行する必要があります。

route.setStartCoordinate(new SKCoordinate(startPointPlace.getLongitude(), 
    startPointPlace.getLatitude())); 

route.setDestinationCoordinate(new SKCoordinate(destinationPointPlace.getLongitude(), 
    destinationPointPlace.getLatitude())); 
関連する問題