I have a list of 26 coordinates, coordinates might increase in future. I am basically trying to draw a route/polyline around Australia. I want to draw the whole route/polyline in a single route builder call. There are 2 limitations right now.
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
}
})
- Cannot add more than 25 coordinates as way points in the request.
- Maximum total distance cannot be more than 10,000 kilometers between all waypoints. It is 12,000 KM in my case.
as mentioned here https://docs.mapbox.com/api/navigation/
I have already contacted technical support and they are not responding to my requests. Let me know if there is any workaround or I will have to make two calls to achieve this.