Android Yandex mapkit路线

时间:2015-08-12 10:22:39

标签: android mapkit yandex

我使用yandexmapkit-android处理项目。图书馆链接为https://github.com/yandexmobile/yandexmapkit-android

文档很弱,github页面不新鲜。最后更新是3年前。

我想画两点之间的路线,但我找不到任何这个或例子的功能或方法

你能帮助我吗?

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

see yandex mapkit demo

 mtRouter = MapKitFactory.getInstance().createMasstransitRouter();
    mtRouter.requestRoutes(ROUTE_START_LOCATION, ROUTE_END_LOCATION,
            new MasstransitOptions(new ArrayList<String>(), new ArrayList<String>(),
                    // Specify departure time or arrival time here
                    new TimeOptions()),
            this);

答案 2 :(得分:0)

// add points
List<RequestPoint> requestPoints = new ArrayList<>();  
DrivingOptions drivingOptions = new DrivingOptions();   
DrivingRouter drivingRouter = MapKitFactory.getInstance().createDrivingRouter();
            DrivingSession drivingSession = drivingRouter.requestRoutes(
                requestPoints, drivingOptions, new DrivingSession.DrivingRouteListener() {
                    @Override
                    public void onDrivingRoutes(List<DrivingRoute> routes) {
                        if (routes != null
                            && !routes.isEmpty()) {
                            DrivingRoute route = routes.get(0);

                        BoundingBox box = BoundingBoxHelper.getBounds(route.getGeometry());
                        CameraPosition boundingBoxPosition = yandexMap.getMap()
                            .cameraPosition(box);
                    }
                }

                @Override
                public void onDrivingRoutesError(Error error) {
                    //showErrorMessage                    }
            });

您可以轻松使用此方法并设置相机位置

希望它对您有用