我正在使用 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)")
}
}
最佳答案
关于ios - ios 中的 mapbox direction api 错误路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36764475/