3

我使用 yandexmapkit-android 进行项目。图书馆链接是https://github.com/yandexmobile/yandexmapkit-android

文档非常薄弱,github 页面也不新鲜。最后一次更新是 3 年前。

我想在两点之间绘制路线,但我找不到这个或示例的任何函数或方法

你能帮助我吗 ?

4

3 回答 3

0

正如我所看到的,有两种方法可以做到这一点。首先是调用 Yandex Navigator 作为外部应用程序:https ://github.com/yandexmobile/yandexmapkit-android/wiki/%D0%98%D0%BD%D1%82%D0%B5%D0%B3%D1%80 %D0%B0%D1%86%D0%B8%D1%8F-%D1%81-%D0%9C%D0%BE%D0%B1%D0%B8%D0%BB%D1%8C%D0%BD %D1%8B%D0%BC%D0%B8-%D0%AF%D0%BD%D0%B4%D0%B5%D0%BA%D1%81.%D0%9A%D0%B0%D1%80 %D1%82%D0%B0%D0%BC%D0%B8

第二种是使用带有 WebView 的 Yandex JS API:https ://tech.yandex.ru/maps/doc/jsapi/2.0/ref/reference/route-docpage/

于 2016-04-05T16:48:37.103 回答
0

参见 yandex mapkit 演示

 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);
于 2018-10-10T10:53:08.670 回答
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                    }
            });

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

希望这对你有用

于 2018-10-31T14:04:37.360 回答