bbrame
bbrame

Reputation: 18544

Mapbox iOS Avoid Motorways / Highways

The Mapbox web directions API supports avoiding motorways Link.

How is this done in the Mapbox iOS SDK?

Upvotes: 0

Views: 282

Answers (1)

The Mapbox Navigation SDK for iOS uses Directions objects to provide directions between waypoints. You may provide a RouteOptions object to each Direction to specify criteria for the results returned by the Mapbox Directions API. As noted in the changelog for the SDK here, on the RouteOptions object there is a roadClassesToAvoid option where you can specify a RoadClass object to avoid, such as motorway. The source code for the motorway RoadClass can be found here, namely:

public static let motorway = RoadClasses(rawValue: 1 << 3)

The Nav SDK's NavigationRouteOptions extends RouteOptions. So, to calculate directions avoiding motorways in your iOS app, you should specify the roadClassesToAvoid option on a NavigationRouteOptions passed to Directions.shared.calculate. This example for a basic navigation app is a great place to get started.

Upvotes: 2

Related Questions