Получите ETA из пункта A в пункт B, используя Apple Mapkits - PullRequest
0 голосов
/ 13 мая 2019

Я пытаюсь получить ETA из моего текущего местоположения в someDestination с помощью Apple MapKits.Но похоже, что MKDirections.Request () не работает.Я использую Swift 5.

let request = MKDirections.Request()


// Get error from this line
let request.source = MKMapItem(placemark:
    MKPlacemark(coordinate:CLLocationCoordinate2D(latitude: 37.325539,
                                                  longitude: -122.011780), addressDictionary: nil))


// Get error from this line
let request.destination = MKMapItem(placemark:
    MKPlacemark(coordinate:CLLocationCoordinate2D(latitude: 37.325539,
                                                  longitude: -122.011780), addressDictionary: nil))

request.transportType = .automobile

let directions = MKDirections.init(request: request)()



// Get error from this line
directions.calculateETA {
    (response, error) -> Void in
    if error == nil {
        if let estimate = response {
            print("Travel time \(estimate.expectedTravelTime / 60)")
            print("Departing at \(estimate.expectedDepartureDate)")
            print("Arriving at \(estimate.expectedArrivalDate)")
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...