【问题标题】:Is it possible in mapbox directions api to avoid a certain point?是否可以在 mapbox 方向 api 中避免某个点?
【发布时间】:2020-01-14 15:06:57
【问题描述】:

我需要该应用生成避开特定点的路线。有可能吗?

private void getRoute(Point origin, final Point destination) {
    NavigationRoute.builder(this)
            .accessToken(Mapbox.getAccessToken())
            .origin(origin)
            .destination(destination)
            .build()
            .getRoute(new Callback<DirectionsResponse>() {
                @Override
                public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
                    // You can get the generic HTTP info about the response
                    Log.d(TAG, "Response code: " + response.code());
                    if (response.body() == null) {
                        Log.e(TAG, "No routes found, make sure you set the right user and access token.");
                        return;
                    } else if (response.body().routes().size() < 1) {
                        Log.e(TAG, "No routes found");
                        return;
                    }

                    currentRoute = response.body().routes().get(0);

                    // Draw the route on the map
                    if (navigationMapRoute != null) {
                        navigationMapRoute.removeRoute();
                    } else {
                        navigationMapRoute = new NavigationMapRoute(null, mapView, map, R.style.NavigationMapRoute);
                    }
                    navigationMapRoute.addRoute(currentRoute);

                }

                @Override
                public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
                    Log.e(TAG, "Error: " + throwable.getMessage());
                }
            });
}

当 statusValue = 1 时,我需要路线图避开特定点,符号层显示(图中的水波),并将这些点标记为不良路线或受限路线。为用户创建替代路线,找到到达目的地的方法。我覆盖了 2 条街道,其中一条在图片中。

【问题讨论】:

  • 有代码示例吗?
  • 完成添加代码

标签: android mapbox directions mapbox-android map-directions


【解决方案1】:

不,不是真的。您可以尝试的一个非常粗略的实验是传递远离您要避开的点的 Directions API 坐标,以便路线避开这些坐标/区域。

https://docs.mapbox.com/android/java/overview/directions/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    相关资源
    最近更新 更多