3

I work on project with yandexmapkit-android. Library link is https://github.com/yandexmobile/yandexmapkit-android

Documentation is very weak and github page is not fresh. Last update is 3 years ago.

I wanna draw route between two point but i can't find any function or method for this or example

Can you help me ?

ahmetkocabiyik
  • 127
  • 3
  • 9

3 Answers3

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);
Abror Esonaliev
  • 11,797
  • 2
  • 23
  • 20
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                    }
            });

You can easily use this method and set camera position

Hope it works for you

abdlkdr
  • 152
  • 2
  • 14