Directions
Getting Directions to a Location
var origin:MPPoint = MPPoint(lat: 38.897382, lon: -77.037447, zValue:0)
var destination:MPPoint = MPPoint.init()
private let renderer = MPDirectionsRenderer()func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let location:MPLocation = searchResult![indexPath.row]
self.destination = location.getPoint()!
self.mapControl?.go(to: location)
tableView.removeFromSuperview()
directions()
}func directions() {
let directions = MPDirectionsService()
let directionsQuery = MPDirectionsQuery(originPoint: origin, destination: destination)
directions.routing(with: directionsQuery) { (route, error) in
self.renderer.map = self.mapView
self.renderer.route = route
self.renderer.routeLegIndex = 0
self.renderer.animate(5)
}
}Expected Result

Last updated
Was this helpful?