使用 MapBox 绘制一个 route/polyline 超过 25 waypoints/coordinates

Draw a route/polyline using MapBox with more than 25 waypoints/coordinates

我有26个坐标的列表,以后坐标可能会增加。我基本上是想在澳大利亚周围画一个 route/polyline。我想在单个路由生成器调用中绘制整个 route/polyline。目前有 2 个限制。

val routeBuilder = NavigationRoute.builder(mContext).accessToken(MapBoxUtils.MAP_KEY).origin(startPoint!!).destination(it)
                .profile(DirectionsCriteria.PROFILE_CYCLING)

            val endIndex = checkPointList.size - 1
            for ((index, point) in checkPointList.withIndex()) {
                if (index != 0 && index < endIndex) {
                    routeBuilder.addWaypoint(Point.fromLngLat(point.coordinates.longitude.toDouble(), point.coordinates.latitude.toDouble()))
                }
            }


            routeBuilder.build().getRoute(object:Callback<DirectionsResponse> {
                override fun onFailure(call: Call<DirectionsResponse>, t: Throwable) {
                    Timber.e("Error: " + t.message)
                }

                override fun onResponse(call: Call<DirectionsResponse>, response: Response<DirectionsResponse>) {
                    if (response.body() == null) {
                        showToast(getErrorMessage(response.errorBody()!!.string()))
                        return
                    } else if (response.body()!!.routes().size < 1) {
                        showToast("No routes found")
                        return
                    } else{
                    //draw route here
                }

            })
  1. 在请求中添加的坐标不能超过 25 个。
  2. 所有 waypoints 之间的最大总距离不能超过 10,000 公里。在我的情况下是 12,000 KM。

如此处所述https://docs.mapbox.com/api/navigation/

我已经联系了技术支持,但他们没有回应我的请求。让我知道是否有任何解决方法,否则我将不得不进行两次调用才能实现此目的。

终于收到MapBox技术支持的回复了

Thank you for using Mapbox! As noted in our documentation for Directions API restrictions and limits, there is a limit of 300 requests per minute, with up to 25 waypoints along each route. The limit of 10,000 kilometers between all waypoints cannot be changed. However, you could consider making multiple requests to the Directions API and then concatenating the results together. For example, "Port Hedland" could be the last destination passed to one API request, and also the first destination passed to the next API request. Concatenating the resulting routes would generate a continuous line.