Display a Map
Display a Map with MapsIndoors
Import MapsIndoors and use MPMapControl
https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController.swift#L1-L52
import GoogleMaps
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GMSServices.provideAPIKey(AppDelegate.gApiKey!)
return true
}import MapsIndoorsCore
import MapsIndoorsGoogleMaps
import GoogleMaps
override func viewDidLoad() {
super.viewDidLoad()
// Set up the Google Maps view. Centered on The White House. Change this to center on a building in your MapsIndoors dataset
let camera = GMSCameraPosition.camera(withLatitude: 38.8977, longitude: -77.0365, zoom: 20)
mapView = GMSMapView.map(withFrame: view.bounds, camera: camera)
view.addSubview(mapView)
// Set up the autoresizing mask to keep the map's frame synced with the view controller's frame.
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
// Initialize the MPMapConfig with the GMSMapView
mapConfig = MPMapConfig(gmsMapView: mapView, googleApiKey: [YOUR_GOOGLE_API_KEY])
// Initialize the MPMapControl with the MPMapConfig.
Task {
// Load MapsIndoors with the MapsIndoors API key.
try await MPMapsIndoors.shared.load(apiKey: [YOUR_MAPSINDOORS_API_KEY])
if let mapConfig = mapConfig {
mapControl = MPMapsIndoors.createMapControl(mapConfig: mapConfig)
// Use MapsIndoors SDK to add your functionality.
// ...
}
}
}Expected Result

Last updated
Was this helpful?