0

我有两个AutoCompleteTextView作为起点和终点。在onCreate()方法中,对于起点,我使用:

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

如何设置起点坐标和终点坐标,以便绘制路线?

4

1 回答 1

2

如果我理解正确的问题,您只需要这样做:

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

route.setDestinationCoordinate(new SKCoordinate(destinationPointPlace.getLongitude(),
    destinationPointPlace.getLatitude()));
于 2016-11-28T14:49:02.883 回答