Mapbox与快速3.0并没有绘制一个折线。
(Swift 2.3工作正常)
Swift 3版本:
for coord in coordsArray! {
let lat = coord.array?.first?.double
let lon = coord.array?.last?.double
let point = CLLocationCoordinate2D(latitude: lat!, longitude: lon!)
coordsArrayValues.append(point)
}
completionHandler(coordsArrayValues)在完成处理方法中:
var rectangle: MGLPolyline?
var coordsArrayValues = coordinatesArray
// draw a route
rectangle = MGLPolyline(coordinates: &coordsArrayValues, count: UInt(coordsArrayValues.count))
if let rectangle = rectangle {
complection(rectangle)
}以下是调试器在about MGLPolyline和coordsArrayValues:(lldb) po coordsArrayValues▿8元素▿0: CLLocationCoordinate2D -纬度: 37.609333999999997 -经度: 55.750295000000001▿1: CLLocationCoordinate2D -纬度: 37.609400999999998 -经度: 55.750410000000002▿2: CLLocationCoordinate2D -纬度: 37.609442999999999 -经度: 55.750495000000001▿3: CLLocationCoordinate2D -纬度: 37.609763000000001 -经度:55.75103899999999999▿4: CLLocationCoordinate2D -纬度: 37.609966999999997 -纬度:经度: 55.751409000000002 CLLocationCoordinate2D 5:纬度: 37.610123999999999 -经度: 55.751694000000001▿6: CLLocationCoordinate2D -纬度: 37.610168000000002 -经度: 55.751823999999999▿7: CLLocationCoordinate2D -纬度: 37.610219999999998 -经度: 55.751918000000003,
。
后来我称之为:
self?.routeService.getRoute(coordinatesArray: coordinates, complection: { [weak self] polyline in
self?.output.showRoute(polyline: polyline)
})在ViewController中,它只是作为一个注释添加:
func showRoute(polyline: MGLPolyline) {
DispatchQueue.main.async { [weak self] in
self?.mapView.addAnnotation(polyline)
}
}发布于 2016-11-15 09:15:58
修正了pod更新(从Mapbox 3.3.5到3.3.6版本)。
https://stackoverflow.com/questions/40599540
复制相似问题