You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Mapbox Team! I have been using Mapbox for my app to generate route and turn-by-turn navigation and it's working well. However I would like to avoid to go through some coordinates of the route but I can't figure it out.
The code to get the route :
Directions.shared.calculate(options) { [unowned self] (waypoints, routes, error) in
// Take first route and customize it in a way to get around some coordinates
}
Here is a scenario :
1- User location is latitude = 37.332331410000002, longitude = -122.0312186
2- The user is going to Santa Clara Unified School located on latitude = 37.354100000000003,longitude = -121.9552
4- Suppose the generated route goes through East Homestead Rd, I would like to be able to avoid this road and generate a new route even if it's a longer one.In the screen below avoid the route in red because going through East Homestead Rd and take the next fastest route not going through East Homestead Rd enter image description here
Any help would be appreciated !
The text was updated successfully, but these errors were encountered:
The Directions API doesn’t currently support avoiding specific areas, only certain road types.
As a workaround, perhaps you could write heuristics for this purpose. If you see that the route comes within some distance of the location you want to avoid (by calling LineString.closestCoordinate(to:) and checking the return value’s distance), you could recalculate the route, this time passing an alternative location as a via point (setting separatesLegs to false on the waypoint).
This is at best a limited workaround, but since there’s no underlying support in the Directions API for the actual feature you’re requesting, I’m closing this issue until things change.
Hi Mapbox Team! I have been using Mapbox for my app to generate route and turn-by-turn navigation and it's working well. However I would like to avoid to go through some coordinates of the route but I can't figure it out.
The code to get the route :
Here is a scenario :
1- User location is
latitude = 37.332331410000002, longitude = -122.0312186
2- The user is going to Santa Clara Unified School located on
latitude = 37.354100000000003,longitude = -121.9552
3- The Api generates the following route :
4- Suppose the generated route goes through East Homestead Rd, I would like to be able to avoid this road and generate a new route even if it's a longer one.In the screen below avoid the route in red because going through East Homestead Rd and take the next fastest route not going through East Homestead Rd enter image description here
Any help would be appreciated !
The text was updated successfully, but these errors were encountered: