All docschevron-rightMaps SDK for iOSchevron-rightarrow-leftExampleschevron-rightSwiftUI - Show me the map!

SwiftUI - Show me the map!

SwiftUI Map with camera observation and automatic dark mode support.

SimpleMapExample.swift
import SwiftUI
@_spi(Experimental) import MapboxMaps
@available(iOS 14.0, *)
struct SimpleMapExample: View {
@Environment(\.colorScheme) var colorScheme
var body: some View {
let polygon = Polygon(center: .helsinki, radius: 10000, vertices: 30)
Map(initialViewport: .overview(geometry: polygon))
.mapStyle(.standard(lightPreset: colorScheme == .light ? .day : .dusk))
.ignoresSafeArea()
}
}
@available(iOS 14.0, *)
struct SimpleMapExample_Previews: PreviewProvider {
static var previews: some View {
SimpleMapExample()
}
}
Was this example helpful?