基于GPX文件的路线计算
Route calculation based on GPX File
我在使用 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曲目时,不出现曲目)
提前谢谢你,我很绝望:'( !
好的,演示项目又漏掉了一些行...
我只需添加这些行即可使其工作:
SKRoutingService.sharedInstance().navigationDelegate = self
SKRoutingService.sharedInstance().routingDelegate = self
SKRoutingService.sharedInstance().mapView = map
希望对大家有所帮助:)
我在使用 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曲目时,不出现曲目)
提前谢谢你,我很绝望:'( !
好的,演示项目又漏掉了一些行... 我只需添加这些行即可使其工作:
SKRoutingService.sharedInstance().navigationDelegate = self
SKRoutingService.sharedInstance().routingDelegate = self
SKRoutingService.sharedInstance().mapView = map
希望对大家有所帮助:)