2016-02-07 58 views
2

我堅持了導航問題,同時使用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 { 

     } 

我試圖得到一些幫助雨燕Skobbler演示,但他們也有問題...... (當選擇柏林GPX軌跡,例如,沒有出現軌道)

預先感謝您,我絕望了!「(

回答

2

好吧,再次示範項目錯過了一些線... 我只需要添加這些線,使其工作:

SKRoutingService.sharedInstance().navigationDelegate = self 
    SKRoutingService.sharedInstance().routingDelegate = self 
    SKRoutingService.sharedInstance().mapView = map 

希望它可以幫助別人:)

+0

嗨。我實際上面臨同樣的問題。嘗試讓演示應用中的曲目繪製路線。你能否澄清一下你添加了這三行代碼?提前致謝! – miguelcaires

+1

嗨@miguelcaires!您可以將它們添加到ViewDidLoad中,並在SKRoutingService.sharedInstance()。calculateRoute(routeSetting)之前添加它們。 – GrayFox