尝试获取从A到B的路线并在mapView上绘图,但编译器说'折线'不可用:从iOS7及更早版本弃用的API在Swift中不可用
在这里看到了类似的帖子:How to use MKPolylineView in Swift,但在这种情况下,它是'折线'这不起作用,而不是其他属性。
有关解决方法的任何想法?
谢谢!
var req: MKDirectionsRequest = MKDirectionsRequest()
req.setSource(MKMapItem(placemark: MKPlacemark(coordinate: start, addressDictionary: nil)))
req.setDestination(MKMapItem(placemark: MKPlacemark(coordinate: dest, addressDictionary: nil)))
var dir: MKDirections = MKDirections(request: req)
dir.calculateDirectionsWithCompletionHandler ({
(response: MKDirectionsResponse?, error: NSError?) in
if let routes = response?.routes{
for route in routes{
println(route.polyline)
self.mapView.addOverlay(route.polyline) // <- this line gives the error
}
}
})
答案 0 :(得分:1)
感谢Martin R,向MKRoute投掷诀窍