1

I have a problem with Sygic maps framework, I tried to show the map using this code in the AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        SYContext.initWithAppKey("mhives.sdk.trial", appSecret: "2nxScQJ0s/J6FsYJ67dlQ+MZLjLzOKc0s96l0t4YyLv2IH8b31b5vWgkzbfgJZ8FYEKQtxpLFGlwyfqEQ64MSQ==") { (initResult) in
        if (initResult == .success) {
            self.window = UIWindow(frame: UIScreen.main.bounds)
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let initialViewController:ViewController = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
            // Set that ViewController as the rootViewController
            self.window?.rootViewController = initialViewController
            self.window?.makeKeyAndVisible()
            initialViewController.sdkDidStart()

        } else {
            print("KO")
        }
    }
        return true
    }

the ViewController.swift

class ViewController: UIViewController,SYMapViewDelegate,SYRoutingDelegate {
let mapView = SYMapView()
let routing = SYRouting()
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    func mapView(_ mapView: SYMapView, didFinishInitialization success: Bool) {
        let tiltFor2D: SYAngle = 0
        mapView.tilt = tiltFor2D
        self.mapView.zoom = 10
        self.mapView.rotation = 180
        self.mapView.geoCenter = SYGeoCoordinate(latitude: 48.147, longitude: 17.101878)!
        self.mapView.frame = self.view.bounds
        view.addSubview(self.mapView)

    }

    func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate: SYGeoCoordinate) {
        // Create an instance of SYRouting


        // Make self a delegate for SYRouting to receive and handle SYRoutingDelegate responses

        // Create SYWaypoint from coordinate. Set correct SYWaypointType for start and finish.
        let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: nil)
        let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: nil)

        // Optionally: create an instance of SYRoutingOptions for configuring computing of a route
        let routingOptions = SYRoutingOptions()
        routingOptions.transportMode = .pedestrian // For other options see SYTransportMode
        routingOptions.routingType = .economic// For other options see SYRoutingType

        // Start computing route
        self.routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
    }

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

    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)
    }

Now I try to show simply the Sygic maps but I didn't get it and I receive this message in the debugger "Sygic: W 18/08/19 17:04:51 No SSO session, unable to send http request!"

func sdkDidStart(){

           mapView.delegate = self
            routing.delegate = self

            self.mapView.frame = self.view.bounds
            self.view.addSubview(self.mapView)
            let start = SYGeoCoordinate(latitude: 37.276758, longitude: 9.864160900000002)
            let end = SYGeoCoordinate(latitude: 37.25408, longitude:  9.906733)
            //computeRoute(from: start!, to: end!)
        }

Any help please

Walid Sassi
  • 185
  • 2
  • 16

1 Answers1

4

First of all do you have valid key and secret? If not you can request one here: https://www.sygic.com/business/request-sygic-mobile-sdk-api-key?product=mobileSdk I understand you are not using real one here in example, but at least the error seems like the one you are using isn't valid.

The other thing is, when do you initialize your SYMapView? If you load ViewController as initial view controller using storyboard for example, then it will try to load map view instance and all of its underlying components before the SDK is fully loaded. Be careful, you should only work with SDK after it is successfully initialized.

So check your API keys and try to initialise that view controller in SYContext.initWithAppKey() completion handler.

anonym
  • 136
  • 5
  • thank you I got a valid key but I still get an empty map. I used the official documentation but it's not worked. Honestly, I didn't understand your idea about sdk initialization – Walid Sassi Aug 23 '18 at 22:23
  • I made some changes in the code but I Still get the empty map – Walid Sassi Aug 23 '18 at 22:35
  • Hi @anonym I made the changes and now the mapview is loaded after the sdk is initialized but I Still get an empty map. please have you an idea ??? – Walid Sassi Aug 25 '18 at 13:33
  • @WalidSassi did you get black map or kind of grey one? the latter means the map view is loaded correctly but there are no maps downloaded or the online map download failed, if it is black there is some other problem... – anonym Aug 27 '18 at 18:36
  • yes I get the grey map kind and when I zoomed out I get all the global earth but without the tiles. I think is the issue in the arcgis sdk – Walid Sassi Sep 01 '18 at 19:13
  • Try calling this `SYOnlineSession.shared().onlineMapsEnabled = true` in your `SYContext.initWithApiKey()` completion handler, this will enable online maps, otherwise you have to load maps explicitly. If you want to use offline maps have a look at `SYMapLoader` which handles downloading and loading maps in SDK. – anonym Sep 02 '18 at 17:03