【问题标题】:Set route line between two point (start point and end point) in Skobbler Map Android在 Skobbler Map Android 中设置两点(起点和终点)之间的路线
【发布时间】:2016-11-18 06:10:31
【问题描述】:

我有两个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());

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

【问题讨论】:

    标签: android skmaps skobbler-maps


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-03-31
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 2016-07-24
      • 2019-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多