Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2017 12:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
func calculateRoute( from startPosition:NMAGeoCoordinates, to endPosition: NMAGeoCoordinates) -> Void {
// set routing options - avoid some road types explicitly
let ro = NMARoutingOption.avoidTollRoad.rawValue | NMARoutingOption.avoidCarpool.rawValue | NMARoutingOption.avoidBoatFerry.rawValue | NMARoutingOption.avoidDirtRoad.rawValue
// setup routing mode for transport type and mode
let rm = NMARoutingMode(routingType: NMARoutingType.balanced, transportMode:, routingOptions: ro)
// create a list of waypoints (start and end but no stopovers)
let waypoints = [startPosition, endPosition]
// routing penalties - we want traffic optimized routing
let dp = NMADynamicPenalty()
dp?.trafficPenaltyMode = NMATrafficPenaltyMode.optimal
cr.dynamicPenalty = dp
// next: kick off route calculation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment