小编Mes*_*esh的帖子

谷歌地图2点之间的路线多路点swift ios

我有这段代码,但由于某种原因,它只是在 2 个点(第一个和最后一个点)之间绘制了一条路线,而忽略了所有其他点,即 [index == 1 to index == n-1 ]

输出:仅在 2 个标记之间路由

预期输出:所有标记之间的路由(5 个标记)

有没有人知道我的代码有什么问题?

 func getDotsToDrawRoute(positions : [CLLocationCoordinate2D], completion: @escaping(_ path : GMSPath) -> Void) {
    if positions.count > 1 {
        let origin = positions.first
        let destination = positions.last
        var wayPoints = ""
        for point in positions {
            wayPoints = wayPoints.characters.count == 0 ? "\(point.latitude),\(point.longitude)" : "\(wayPoints)|\(point.latitude),\(point.longitude)"
        }
        print("this is fullPath :: \(wayPoints)")
        let request = "https://maps.googleapis.com/maps/api/directions/json"
        let parameters : [String : String] = ["origin" : "\(origin!.latitude),\(origin!.longitude)", …
Run Code Online (Sandbox Code Playgroud)

google-maps ios swift3

4
推荐指数
1
解决办法
2309
查看次数

标签 统计

google-maps ×1

ios ×1

swift3 ×1