Getting Started: All-in-one

Prerequisites

  1. Add the following Mapsted pods to your project pod file. Make sure use_frameworks! is included.

    • pod 'mapsted-mobile-sdk'
    • pod 'mapsted-map-sdk'
  2. Include the following pod sources. You will need access to the github repository to install teh Mapsted pods.

    • source 'https://github.com/CocoaPods/Specs.git'
    • source 'https://github.com/Mapsted/podspec.git'
  3. Run pod install if installing first time or pod update if updating pods.

  4. Make sure the Mapsted license file is added to your project. If you do not have a license, please contact sales for more information.


Basic Integration

  1. Add location usage description for NSLocationAlwaysUsageDescription key in project's Info.plist file. Location is required in background to support navigation. In Xcode, under app capabilities, enable location updates for background:

  2. Add the following imports:

    • import positioning
    • import map
    • import mapuikit
  3. Add sdk initialization code in AppDelegate:

        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            MNSettingUtils.setVLog(false)
            MNSettingUtils.setWtfAbort(false)
            MNMapApi.shared.setUp(prefetchProperties: false) {}
            return true
        }
    
  4. Add your view controller as observer for SDK initialized notification. You can present the Mapsted map view controller here. The map will not load until SDK is initialized.

        override func viewDidLoad() {
            super.viewDidLoad()
            MNCoreNotificationManager.main.addObserver(type: .initialized, observer: self, selector: #selector(self.initialized(notification:)))
    
            if let mapsVC = MNMapUIKitViewController.shared as? MNMapUIKitViewController {
                self.mapsVC = mapsVC
                containerVC?.addController(controller: mapsVC, yOffset: 0, isNew: false)
                mapsVC.showLoadingSpinner(text: "Loading...")
            }
        }
    
  5. In the SDK initialized notification handler, you can draw a property and center map on that property.

        @objc func initialized(notification: NSNotification) {
            DispatchQueue.main.async {
                self.mapsVC?.hideLoadingSpinner()
                let propertyInfos = MNPositioningApi.shared.propertyInfos()
                if propertyInfos.count > 0 {
                    self.mapsVC?.selectAndDrawProperty(propertyId: propertyInfos[0].propertyId(), callback: {status in
                        if status {
                            self.mapsVC?.displayPropertyOnMap()
                        }
                    })
                }
            }
        }
    

    The Mapsted map view controller will look like this: