Created
January 26, 2017 12:56
-
-
Save here-devblog-gists/59d985ef356f09a8ba6f54078b5caa25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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