gpt4 book ai didi

swift - 基于GPX文件的路线计算

转载 作者:可可西里 更新时间:2023-11-01 01:37:25 24 4
gpt4 key购买 nike

我在使用 GPX 文件创建路线导航(逐个转弯)时遇到导航问题

我的 GPX 文件解析似乎工作正常,因为我已经设法构建了一个 CLLocation 数组。

问题是我的 map View 上没有显示任何内容。我也没有路由委托(delegate)回调(事件: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

希望它可以帮助某人:)

关于swift - 基于GPX文件的路线计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35255474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com