Skip to main content
Version: 3.0

Getting Started

Introduction

Mappedin SDK for iOS helps you deliver the rich indoor mapping experience of your venue, designed in Mappedin CMS, inside your iOS apps.

In this overview, we will go through the basic concepts that will help you understand how the SDK works. In further sections, we'll also go through the setup and usage of the Mappedin SDK for iOS.

The iOS SDK is simply a native interface to the Web SDK. The SDK is a framework built using Swift, and it automatically handles any authentication, network communication, fetching of map data, its display, and basic user interaction, such as panning, tapping, and zooming. The SDK allows you to build your own interactions. You can render your own additional layers on top of the map that the SDK renders.

Concepts

  • After the quick initial setup and configuration, the SDK renders the maps associated with the keys provided by you, inside an MPIMapView instance you created.
  • The SDK allows you to render your venue's maps in 3D. The SDK pulls the most up-to-date data from our mapping CMS for all your points of interest within your venue.
  • The SDK supports drawing navigation paths and providing instructions to and from any point of interest within the venue. Both accessible and non-accessible optimized routes are supported. You can build more functionality on top of this experience, such as searching or switching venues.

Further pieces of this guide give you more details about how to set up the SDK and customize it as per your liking.

Quickstart

This quickstart guide is written for a new Storyboard application that has been initialized with Cocoapods.

Add dependency to CocoaPods

Mappedin's SDK is available through CocoaPods. You can find the latest version on Github. To install it, add the dependency to your Podfile in your project's root directory:

pod 'MappedIn', '3.0.7'

For more information on how to use Cocoapods, see here.

In order for your project to recognize the Pods framework, you must be working from the .xcworkspace file rather than the individual .xcproj file. If you started a new project from scratch in Xcode, you'll need to close it and open the workspace.

Make sure platform :ios, '11.0' is set to version 11.0 at minimum.

Your Podfile should now have at least the following information with your own app name replacing mappedin-ios-sdk-app:

platform :ios, '11.0'

target 'mappedin-ios-sdk-app' do
use_frameworks!

pod 'MappedIn', '3.0.7'
end

In the terminal, run pod install in your project's root directory.

To import the module into the project, add the following line to your ViewController:

import Mappedin

Refer to our Github repository to view the sample app created by Mappedin developers to understand how to embed a map into your app.

Display the Venue

Creating the MPIMapView instance

Now we are ready to initialize an MPIMapView instance mapView in the viewDidLoad() method of your ViewController and add it to the layout:


var mapView: MapView?

override func viewDidLoad() {
super.viewDidLoad()

let screenRect = UIScreen.main.bounds
let screenWidth = screenRect.size.width
let screenHeight = screenRect.size.height

// Set up MPIMapView and add to view
mapView = MPIMapView(frame: CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight))
if let mapView = mapView {
self.view.insertSubview(mapView, at: 0)
}
}

Load the Venue

loadVenue is a MPIMapView function that allows you to render the venue in your app by passing in an options object and an optional showVenueOptions object.

The required properties of options object are venue, clientId, clientSecret. To get you started, we’ve provided a Mappedin id and secret that has access to some demo venues. When you’re ready to start using your own venues with the SDK, you will need to contact a Mappedin representative to get your own unique id and secret.

PropertyValue
venuemappedin-demo-mall
clientIdSee Here
clientSecretSee Here

You can also pass in showVenueOptions to modify the properties of the map such as the background color, the map that is displayed first and whether all locations are labeled on initialization. Add the following mapView.loadVenue call inside the optional unwrapping of mapView.

mapView.loadVenue(options:
MPIOptions.Init(
clientId: "5eab30aa91b055001a68e996",
clientSecret: "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
venue: "mappedin-demo-mall",
headers: [MPIHeader(name: "name", value: "value")]),
showVenueOptions: MPIOptions.ShowVenue(
labelAllLocationsOnInit: true,
backgroundColor: "#ffffff"
))

Showing cached venue data

showVenue is an alternative method to load the venue without using any API calls to retrieve the data. Instead, the data must be passed into the showVenue method which takes in a data string (which can be retrieved from a file).

Use this sample JSON file to get started with the showVenue method.

Here is an example:

// use showVenue to load venue
if let path = Bundle.main.path(forResource: "mappedin-demo-mall", ofType: "json") {
venueDataString = try? String(contentsOfFile: path)
if let venueDataString = venueDataString {
mapView.showVenue(
venueResponse: venueDataString,
showVenueOptions: MPIOptions.ShowVenue(labelAllLocationsOnInit: true, backgroundColor: "#CDCDCD")
)
}
}

Result

import UIKit
import Mappedin

class ViewController: UIViewController {

var mapView: MPIMapView?

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let screenRect = UIScreen.main.bounds
let screenWidth = screenRect.size.width
let screenHeight = screenRect.size.height

mapView = MPIMapView(frame: CGRect(
x: 0, y: 0, width: screenWidth, height: screenHeight
))
if let mapView = mapView {
self.view.insertSubview(mapView, at: 0)

mapView.loadVenue(options:
MPIOptions.Init(
clientId: "5eab30aa91b055001a68e996",
clientSecret: "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
venue: "mappedin-demo-mall",
headers: [MPIHeader(name: "name", value: "value")]),
showVenueOptions: MPIOptions.ShowVenue(
labelAllLocationsOnInit: true,
backgroundColor: "#ffffff"
))
}
}
}

You should see something that looks like this:
iOS SDK v4 - quickstart