【问题标题】:Mapbox iOS SDK polyline, swift 3Mapbox iOS SDK折线,swift 3
【发布时间】:2016-11-15 17:15:58
【问题描述】:

带有 swift 3.0 的 Mapbox SDK 不绘制折线。

(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)
    }

这是调试器在 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.751038999999999 ▿ 4 : CLLocationCoordinate2D - 纬度:37.609966999999997 - 经度:55.751409000000002 ▿ 5 : CLLocationCoordinate2D - 纬度: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)
    }
}

【问题讨论】:

  • 能否在设置折线值的地方添加代码并调用showRoute()?
  • @picciano ,折线的值与矩形相加,然后放入完成处理程序。后来它只是像这样移动到视图中: self?.routeService.getRoute(coordinatesArray: coordinates, complection: { [weak self] polyline in self?.output.showRoute(polyline: polyline) })

标签: ios swift swift3 mapbox


【解决方案1】:

通过 pod 更新修复(从 Mapbox 3.3.5 到 3.3.6 版本)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-04
    • 1970-01-01
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 2021-11-16
    • 2017-10-28
    相关资源
    最近更新 更多