我有两个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());
如何设置起点坐标和终点坐标,以便绘制路线?