使用GPX文件创建路线导航时,我遇到导航问题(转弯)
我的GPX文件解析似乎有效,因为我已经设法构建了一个CLLocation数组。
问题是我的地图视图上没有显示任何内容。我也没有路由委托回调(使用事件:didFinishRouteCalculationWithInfo)
这是我的代码:
let path: String = NSBundle.mainBundle().pathForResource(fileName, ofType: "gpx")!
do {
let root: SKGPSFileElement = try SKGPSFilesService.sharedInstance().loadFileAtPath(path)
let locationArray = SKGPSFilesService.sharedInstance().locationsForElement(root)
let route = SKRouteSettings()
route.shouldBeRendered = true
route.requestAdvices = true
SKRoutingService.sharedInstance().calculateRouteWithSettings(route, customLocations: locationArray)
// I also tried to read directly my SKGPSFileElement :
//SKRoutingService.sharedInstance().calculateRouteWithSettings(route, GPSFileElement: root)
} catch {
}
我试图在Swift Skobbler演示中获得一些帮助,但他们也有问题......(例如,当选择柏林GPX赛道时,没有赛道出现)
提前谢谢你,我很绝望:'(!
答案 0 :(得分:2)
好的,演示项目再次错过了一些线路...... 我只需要添加这些行就可以了:
SKRoutingService.sharedInstance().navigationDelegate = self
SKRoutingService.sharedInstance().routingDelegate = self
SKRoutingService.sharedInstance().mapView = map
希望它可以帮助某人:)