2016-11-18 19 views
0

У меня есть два AutoCompleteTextView для начальной и конечной точки. При onCreate() метода для начальной точки, я использую:Настроить линию маршрута между двумя точками (начальная и конечная точки) в Skobbler Map 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(); 
       } 
      } 
     }); 

и конечной точки, я использую:

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(); 
      } 
     } 
    }); 

У меня есть метод route между двумя точками:

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); 
} 

Здесь , 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()));