Skip to content

Instantly share code, notes, and snippets.

@here-devblog-gists
Created January 26, 2017 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save here-devblog-gists/59d985ef356f09a8ba6f54078b5caa25 to your computer and use it in GitHub Desktop.
Save here-devblog-gists/59d985ef356f09a8ba6f54078b5caa25 to your computer and use it in GitHub Desktop.
cr.calculateRoute(withStops: waypoints, routingMode: rm, completionBlock: { routeResult,error in
if error == NMARoutingError.none || error == NMARoutingError.violatesOptions
{
if let r = routeResult?.routes[0] as? NMARoute
{
print("New route received")
// when the route options were too restrictive for the route, we can still get a route back, but with violated options
if error == NMARoutingError.violatesOptions {
// use NMARoutingViolatedOption in NMARouteResult to get the violated options
print("Violated \(routeResult?.violatedOptions.count) route options")
}
if self.mapRoute != nil {
self.map?.remove(self.mapRoute)
}
self.mapRoute = NMAMapRoute(route: r)
self.map?.add(self.mapRoute)
self.map?.setBoundingBox(r.boundingBox, with: NMAMapAnimation.bow)
}
}
else
{
print("ERROR: failed calculatig route: \(error.rawValue)")
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment