我的代码:
let req = MKDirectionsRequest()
req.source = MKMapItem.mapItemForCurrentLocation()
req.destination = destination
let dir = MKDirections(request:req)
if dir.calculating {
print("calculating")
} else {
print("Not Calculating")
}
dir.calculateDirectionsWithCompletionHandler() {
(response:MKDirectionsResponse?, error:NSError?) in
当我打印错误时,它显示如下:
Error Domain=MKErrorDomain Code=1 "Directions Not Available" UserInfo={NSLocalizedFailureReason=Route information is not available at this moment., NSLocalizedDescription=Directions Not Available, MKDirectionsErrorCode=2, MKErrorGEOError=-902}
它总是抛出上面的错误。
我无法得到那些错误键:
MKErrorGEOError = -902
MKDirectionsErrorCode = 2
用Google搜索更多信息,但无法找到它。