mapbox方向api错误路线在ios

时间:2016-04-21 08:51:08

标签: ios swift api mapbox

我使用MapBox(Direction API)绘制两点之间的路线。当我在Mapbox网站上的地图上绘制根时,我得到了正确的路线,但是当我在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)")
                }
            }

mapbox网站: enter image description here

在我的应用中: enter image description here

2 个答案:

答案 0 :(得分:2)

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

MapboxDirections.swift master正确渲染此路线:

答案 1 :(得分:0)

问题已经解决

 for geoCoordinates in route.geometry {
       self.calculatedTourPoints.append(geoCoordinates)
   }