ios - ios 中的 mapbox direction api 错误路线

标签 ios swift api mapbox

我正在使用 MapBox(Direction API)绘制两点之间的路线。当我在 Mapbox 站点的 map 上绘制根时,我得到了正确的路线,但是当我在 iOS 上使用 MapboxDirection API (MapboxDirections.swift) 时,我得到了一条错误的路线(它只是捷径而不是转弯。 网址:https://api.mapbox.com/v4/directions/mapbox.driving/58.3492489633563,37.898002422381;58.3578,37.8787.json?access_token=pk .****&alternatives=true&geometry=折线

directions!.calculateDirectionsWithCompletionHandler { (response, error) in
                if let route = response?.routes.first {
                    print("Route summary:")
                    let steps = route.legs.first!.steps

                    print("Distance: \(route.distance) meters (\(steps.count) route steps) in \(route.expectedTravelTime / 60) minutes")
                    for step in steps {
                        print("\(step.instructions) \(step.distance) meters")

                        self.calculatedTour.append(step)
                        self.calculatedTourPoints.append(step.maneuverLocation)
                    }
                    self.tourLine = MGLPolyline(coordinates: &self.calculatedTourPoints, count: UInt(self.calculatedTour.count))

                    self.mapView.addAnnotation(self.tourLine)
                } else {
                    print("Error calculating directions: \(error)")
                }
            }

map 框网站: enter image description here

在我的应用中: enter image description here

最佳答案

这似乎是对路线的无意过度简化。

MapboxDirections.swift master 正确呈现此路由,但是:

关于ios - ios 中的 mapbox direction api 错误路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36764475/

相关文章:

iphone - 用于 iOS 项目的 XMLRPC-iOS

ios - 为什么在我尝试更新我的解决方案时 Xamarin Studio 说 "version control operation failed due to unmerged path error"?

arrays - 如何搜索和替换 Swift 数组中的值?

swift - Swift 5 中的引用赋值是原子的吗?

ios - 如何设置 uiview 背景和 uiimageview 居中、缩放以填充和 mask 到边界?

ios - 如何覆盖包含 block 的objC中的方法?

ios - 即使出于软件包目的而卸载应用程序后也能唯一地识别 iOS 设备

json - 如何将数据库对象序列化/表示为 Node 中 API 返回的 JSON

php - Zimbra SOAP 创建帐户

node.js - 无法更新 mongodb 中的单个数据