Sygic issue in calculating the route











up vote
1
down vote

favorite












I have a problem when I tried to add a route in my Sygic offline map view. In the debugger, I got this message " Routing interface: Asking for unknown transport mode." this the code that I wrote:



   class SygicMapViewController: UIViewController, SYNavigationDelegate,SYRoutingDelegate,SYMapViewDelegate,CLLocationManagerDelegate{
let mapView = SYMapView()
let routing = SYRouting()
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func setupMapView(){
let tiltFor2D: SYAngle = 0
mapView.tilt = tiltFor2D
mapView.zoom = 12
mapView.rotation = 180
mapView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height:self.view.frame.size.height+20)
self.view.addSubview(mapView)
mapView.renderEnabled = true
}
func addMarkers(){

}
func mapView(_ mapView: SYMapView, didFinishInitialization success: Bool) {
setupMapView()
SYNavigation.shared().delegate = self
routing.delegate = self
let startPoint = SYGeoCoordinate(latitude: 37.270665, longitude: 9.873921)
let endPoint = SYGeoCoordinate(latitude: 37.242681, longitude: 9.911932)
computeRoute(from: startPoint!, to: endPoint!)
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}

func routing(_ routing: SYRouting, computingFailedWithError error: SYRoutingError) {
print(error)
}

func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
let mapRoute = SYMapRoute(route: route!, type: .primary)
mapView.add(mapRoute)
mapView.cameraMovementMode = .followGpsPosition
}
}


I correct the issue by selecting the local routing variable in the computeRoute method and I made some changes to fire the computeRoute method after the mapview Intialization










share|improve this question




























    up vote
    1
    down vote

    favorite












    I have a problem when I tried to add a route in my Sygic offline map view. In the debugger, I got this message " Routing interface: Asking for unknown transport mode." this the code that I wrote:



       class SygicMapViewController: UIViewController, SYNavigationDelegate,SYRoutingDelegate,SYMapViewDelegate,CLLocationManagerDelegate{
    let mapView = SYMapView()
    let routing = SYRouting()
    var locationManager = CLLocationManager()
    override func viewDidLoad() {
    super.viewDidLoad()
    mapView.delegate = self
    locationManager.delegate = self
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    locationManager.requestAlwaysAuthorization()
    locationManager.requestWhenInUseAuthorization()
    locationManager.startUpdatingLocation()
    }
    func setupMapView(){
    let tiltFor2D: SYAngle = 0
    mapView.tilt = tiltFor2D
    mapView.zoom = 12
    mapView.rotation = 180
    mapView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height:self.view.frame.size.height+20)
    self.view.addSubview(mapView)
    mapView.renderEnabled = true
    }
    func addMarkers(){

    }
    func mapView(_ mapView: SYMapView, didFinishInitialization success: Bool) {
    setupMapView()
    SYNavigation.shared().delegate = self
    routing.delegate = self
    let startPoint = SYGeoCoordinate(latitude: 37.270665, longitude: 9.873921)
    let endPoint = SYGeoCoordinate(latitude: 37.242681, longitude: 9.911932)
    computeRoute(from: startPoint!, to: endPoint!)
    }
    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
    print(error)
    }
    override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    }
    func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
    SYGeoCoordinate) {
    let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
    let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
    let routingOptions = SYRoutingOptions()
    routingOptions.transportMode = .unknown// For other options see SYTransportMode
    routingOptions.routingType = .economic// For other options see SYRoutingType
    routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
    }

    func routing(_ routing: SYRouting, computingFailedWithError error: SYRoutingError) {
    print(error)
    }

    func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
    SYNavigation.shared().start(with: route)
    // You might want to put it also on the map
    let mapRoute = SYMapRoute(route: route!, type: .primary)
    mapView.add(mapRoute)
    mapView.cameraMovementMode = .followGpsPosition
    }
    }


    I correct the issue by selecting the local routing variable in the computeRoute method and I made some changes to fire the computeRoute method after the mapview Intialization










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a problem when I tried to add a route in my Sygic offline map view. In the debugger, I got this message " Routing interface: Asking for unknown transport mode." this the code that I wrote:



         class SygicMapViewController: UIViewController, SYNavigationDelegate,SYRoutingDelegate,SYMapViewDelegate,CLLocationManagerDelegate{
      let mapView = SYMapView()
      let routing = SYRouting()
      var locationManager = CLLocationManager()
      override func viewDidLoad() {
      super.viewDidLoad()
      mapView.delegate = self
      locationManager.delegate = self
      locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
      locationManager.requestAlwaysAuthorization()
      locationManager.requestWhenInUseAuthorization()
      locationManager.startUpdatingLocation()
      }
      func setupMapView(){
      let tiltFor2D: SYAngle = 0
      mapView.tilt = tiltFor2D
      mapView.zoom = 12
      mapView.rotation = 180
      mapView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height:self.view.frame.size.height+20)
      self.view.addSubview(mapView)
      mapView.renderEnabled = true
      }
      func addMarkers(){

      }
      func mapView(_ mapView: SYMapView, didFinishInitialization success: Bool) {
      setupMapView()
      SYNavigation.shared().delegate = self
      routing.delegate = self
      let startPoint = SYGeoCoordinate(latitude: 37.270665, longitude: 9.873921)
      let endPoint = SYGeoCoordinate(latitude: 37.242681, longitude: 9.911932)
      computeRoute(from: startPoint!, to: endPoint!)
      }
      func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
      print(error)
      }
      override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
      }
      func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
      SYGeoCoordinate) {
      let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
      let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
      let routingOptions = SYRoutingOptions()
      routingOptions.transportMode = .unknown// For other options see SYTransportMode
      routingOptions.routingType = .economic// For other options see SYRoutingType
      routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
      }

      func routing(_ routing: SYRouting, computingFailedWithError error: SYRoutingError) {
      print(error)
      }

      func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
      SYNavigation.shared().start(with: route)
      // You might want to put it also on the map
      let mapRoute = SYMapRoute(route: route!, type: .primary)
      mapView.add(mapRoute)
      mapView.cameraMovementMode = .followGpsPosition
      }
      }


      I correct the issue by selecting the local routing variable in the computeRoute method and I made some changes to fire the computeRoute method after the mapview Intialization










      share|improve this question















      I have a problem when I tried to add a route in my Sygic offline map view. In the debugger, I got this message " Routing interface: Asking for unknown transport mode." this the code that I wrote:



         class SygicMapViewController: UIViewController, SYNavigationDelegate,SYRoutingDelegate,SYMapViewDelegate,CLLocationManagerDelegate{
      let mapView = SYMapView()
      let routing = SYRouting()
      var locationManager = CLLocationManager()
      override func viewDidLoad() {
      super.viewDidLoad()
      mapView.delegate = self
      locationManager.delegate = self
      locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
      locationManager.requestAlwaysAuthorization()
      locationManager.requestWhenInUseAuthorization()
      locationManager.startUpdatingLocation()
      }
      func setupMapView(){
      let tiltFor2D: SYAngle = 0
      mapView.tilt = tiltFor2D
      mapView.zoom = 12
      mapView.rotation = 180
      mapView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height:self.view.frame.size.height+20)
      self.view.addSubview(mapView)
      mapView.renderEnabled = true
      }
      func addMarkers(){

      }
      func mapView(_ mapView: SYMapView, didFinishInitialization success: Bool) {
      setupMapView()
      SYNavigation.shared().delegate = self
      routing.delegate = self
      let startPoint = SYGeoCoordinate(latitude: 37.270665, longitude: 9.873921)
      let endPoint = SYGeoCoordinate(latitude: 37.242681, longitude: 9.911932)
      computeRoute(from: startPoint!, to: endPoint!)
      }
      func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
      print(error)
      }
      override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
      }
      func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
      SYGeoCoordinate) {
      let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
      let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
      let routingOptions = SYRoutingOptions()
      routingOptions.transportMode = .unknown// For other options see SYTransportMode
      routingOptions.routingType = .economic// For other options see SYRoutingType
      routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
      }

      func routing(_ routing: SYRouting, computingFailedWithError error: SYRoutingError) {
      print(error)
      }

      func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
      SYNavigation.shared().start(with: route)
      // You might want to put it also on the map
      let mapRoute = SYMapRoute(route: route!, type: .primary)
      mapView.add(mapRoute)
      mapView.cameraMovementMode = .followGpsPosition
      }
      }


      I correct the issue by selecting the local routing variable in the computeRoute method and I made some changes to fire the computeRoute method after the mapview Intialization







      swift maps sygic sygic-mobile-sdk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 11:10

























      asked Nov 11 at 8:29









      Walid Sassi

      408




      408
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          I actually see two issues with your code.




          1. In func computeRoute(from fromCoordinate: SYGeoCoordinate, to
            toCoordinate: SYGeoCoordinate)
            you define local variable routing
            which hides instance variable. This causes the routing to be
            deallocated before it can compute any route. So just remove that
            let routing = SYRouting() from that method and use instance
            routing variable.

          2. The other one can also be an issue and cause problems. You start
            routing in viewDidLoad before map is initialised. Then if the
            routing is faster you will be adding SYRoute object to map and
            that would probably crash. I know this is just some quick setup, but
            to avoid any issues move that call to computeRoute at least to
            mapView(_, didFinishInitialization) method.






          share|improve this answer





















          • thank you I resolve the issue by removing local variable routing that block delegate fire
            – Walid Sassi
            Nov 12 at 11:03










          • but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
            – Walid Sassi
            Nov 12 at 11:07












          • if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
            – anonym
            Nov 12 at 12:05












          • thank you you save my day it's not mentioned in the documentation !!!!
            – Walid Sassi
            Nov 12 at 12:52











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247032%2fsygic-issue-in-calculating-the-route%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          I actually see two issues with your code.




          1. In func computeRoute(from fromCoordinate: SYGeoCoordinate, to
            toCoordinate: SYGeoCoordinate)
            you define local variable routing
            which hides instance variable. This causes the routing to be
            deallocated before it can compute any route. So just remove that
            let routing = SYRouting() from that method and use instance
            routing variable.

          2. The other one can also be an issue and cause problems. You start
            routing in viewDidLoad before map is initialised. Then if the
            routing is faster you will be adding SYRoute object to map and
            that would probably crash. I know this is just some quick setup, but
            to avoid any issues move that call to computeRoute at least to
            mapView(_, didFinishInitialization) method.






          share|improve this answer





















          • thank you I resolve the issue by removing local variable routing that block delegate fire
            – Walid Sassi
            Nov 12 at 11:03










          • but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
            – Walid Sassi
            Nov 12 at 11:07












          • if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
            – anonym
            Nov 12 at 12:05












          • thank you you save my day it's not mentioned in the documentation !!!!
            – Walid Sassi
            Nov 12 at 12:52















          up vote
          1
          down vote













          I actually see two issues with your code.




          1. In func computeRoute(from fromCoordinate: SYGeoCoordinate, to
            toCoordinate: SYGeoCoordinate)
            you define local variable routing
            which hides instance variable. This causes the routing to be
            deallocated before it can compute any route. So just remove that
            let routing = SYRouting() from that method and use instance
            routing variable.

          2. The other one can also be an issue and cause problems. You start
            routing in viewDidLoad before map is initialised. Then if the
            routing is faster you will be adding SYRoute object to map and
            that would probably crash. I know this is just some quick setup, but
            to avoid any issues move that call to computeRoute at least to
            mapView(_, didFinishInitialization) method.






          share|improve this answer





















          • thank you I resolve the issue by removing local variable routing that block delegate fire
            – Walid Sassi
            Nov 12 at 11:03










          • but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
            – Walid Sassi
            Nov 12 at 11:07












          • if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
            – anonym
            Nov 12 at 12:05












          • thank you you save my day it's not mentioned in the documentation !!!!
            – Walid Sassi
            Nov 12 at 12:52













          up vote
          1
          down vote










          up vote
          1
          down vote









          I actually see two issues with your code.




          1. In func computeRoute(from fromCoordinate: SYGeoCoordinate, to
            toCoordinate: SYGeoCoordinate)
            you define local variable routing
            which hides instance variable. This causes the routing to be
            deallocated before it can compute any route. So just remove that
            let routing = SYRouting() from that method and use instance
            routing variable.

          2. The other one can also be an issue and cause problems. You start
            routing in viewDidLoad before map is initialised. Then if the
            routing is faster you will be adding SYRoute object to map and
            that would probably crash. I know this is just some quick setup, but
            to avoid any issues move that call to computeRoute at least to
            mapView(_, didFinishInitialization) method.






          share|improve this answer












          I actually see two issues with your code.




          1. In func computeRoute(from fromCoordinate: SYGeoCoordinate, to
            toCoordinate: SYGeoCoordinate)
            you define local variable routing
            which hides instance variable. This causes the routing to be
            deallocated before it can compute any route. So just remove that
            let routing = SYRouting() from that method and use instance
            routing variable.

          2. The other one can also be an issue and cause problems. You start
            routing in viewDidLoad before map is initialised. Then if the
            routing is faster you will be adding SYRoute object to map and
            that would probably crash. I know this is just some quick setup, but
            to avoid any issues move that call to computeRoute at least to
            mapView(_, didFinishInitialization) method.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 21:58









          anonym

          764




          764












          • thank you I resolve the issue by removing local variable routing that block delegate fire
            – Walid Sassi
            Nov 12 at 11:03










          • but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
            – Walid Sassi
            Nov 12 at 11:07












          • if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
            – anonym
            Nov 12 at 12:05












          • thank you you save my day it's not mentioned in the documentation !!!!
            – Walid Sassi
            Nov 12 at 12:52


















          • thank you I resolve the issue by removing local variable routing that block delegate fire
            – Walid Sassi
            Nov 12 at 11:03










          • but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
            – Walid Sassi
            Nov 12 at 11:07












          • if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
            – anonym
            Nov 12 at 12:05












          • thank you you save my day it's not mentioned in the documentation !!!!
            – Walid Sassi
            Nov 12 at 12:52
















          thank you I resolve the issue by removing local variable routing that block delegate fire
          – Walid Sassi
          Nov 12 at 11:03




          thank you I resolve the issue by removing local variable routing that block delegate fire
          – Walid Sassi
          Nov 12 at 11:03












          but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
          – Walid Sassi
          Nov 12 at 11:07






          but I had an issue to fire the navigation now and detect my position in the route that I draw have you an idea about this please ? I made some changes in the code that you can check with me what is wrong
          – Walid Sassi
          Nov 12 at 11:07














          if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
          – anonym
          Nov 12 at 12:05






          if you mean that you want the SDK to start updating position based on your GPS, you need to use SYPositioning this class handles stuff related to that... At least you need to call SYPositioning.shared().startUpdatingPosition() after SDK is initialised, this will handle all the permissions and other stuff you need.
          – anonym
          Nov 12 at 12:05














          thank you you save my day it's not mentioned in the documentation !!!!
          – Walid Sassi
          Nov 12 at 12:52




          thank you you save my day it's not mentioned in the documentation !!!!
          – Walid Sassi
          Nov 12 at 12:52


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247032%2fsygic-issue-in-calculating-the-route%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine