Switching Solutions
Starting a Solution
func setupMapsIndoors(mapsIndoorsAPIKey: String, mapboxAccessToken: String) async throws {
// Set up the Mapbox map view
let mapInitOptions = MapInitOptions(resourceOptions: ResourceOptions(accessToken: mapboxAccessToken))
self.mapView = MapView(frame: self.view.bounds, mapInitOptions: mapInitOptions)
self.view = self.mapView
// Orient your map to where you need data to be shown.
// This can e.g. be done by pointing the camera to a specific location (shown below)
// or getting the default venue after MapsIndoors is loaded and panning the camera there.
let centerCoordinate = CLLocationCoordinate2D(latitude: 57.057964, longitude: 9.9504112, zoom: 20)
self.mapView.mapboxMap.setCamera(to: CameraOptions(center: centerCoordinate, zoom: 20))
// Initialize the MPMapConfig with the Mapbox MapView
self.mapConfig = MPMapConfig(mapBoxView: mapView, accessToken: mapboxAccessToken)
try await MPMapsIndoors.shared.load(apiKey: mapsIndoorsAPIKey)
self.mapControl = MPMapsIndoors.createMapControl(mapConfig: mapConfig)
}func setupMapsIndoors(mapsIndoorsAPIKey: String, googleMapsAPIKey: String) async throws {
// Orient your map to where you need data to be shown.
// This can e.g. be done by pointing the camera to a specific location (shown below)
// or getting the default venue after MapsIndoors is loaded and panning the camera there.
let camera = .camera(withLatitude: 57.057964, longitude: 9.9504112, zoom: 20)
self.mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera)
self.view = self.mapView
// Initialize the MPMapConfig with the GMSMapView
self.mapConfig = MPMapConfig(gmsMapView: self.mapView, googleApiKey: googleMapsAPIKey)
try await MPMapsIndoors.shared.load(apiKey: mapsIndoorsAPIKey)
self.mapControl = MPMapsIndoors.createMapControl(mapConfig: mapConfig)
}Switching Solutions
Last updated
Was this helpful?