Display a 3D terrain map - Swift SDK
This example demonstrates how to create a 3D (three-dimensional) terrain map and display it on your mobile device using MapTiler.
Enhance the authenticity of your applications and data by incorporating terrain relief into your maps. This will provide a greater sense of realism and depth to your visuals.
import SwiftUI
import CoreLocation
import MapTilerSDK
struct ContentView: View {
init() {
// Best practice: set the MapTiler API key on app startup instead on init
// Replace with your MapTiler API key
Task { await MTConfig.shared.setAPIKey("MY_API_KEY") }
}
@State private var mapView = MTMapView(
options: MTMapOptions(
center: CLLocationCoordinate2D(latitude: 8.94738, longitude: 45.97812),
zoom: 14,
maxZoom: 14,
pitch: 70,
maxPitch: 85,
bearing: -100.86,
terrainIsEnabled: true
)
)
var body: some View {
MTMapViewContainer(map: mapView)
.referenceStyle(.outdoor)
}
}
On this page