Skip to main content

Map Render

Last updated: April 24, 2026 | 2 minutes read

This example demonstrates how to use GEMKit in a SwiftUI application to handle the map rendering based on the app's lifecycle.

Check the full implementation on GitHub.

MapBase View

Map Display and Rendering

The following code outlines the main view, which displays the map and manages the rendering state based on the current scene phase:

ContentView.swiftView on GitHub
struct ContentView: View {

@Environment(\.scenePhase) private var scenePhase

@State private var isAppActive = true

var body: some View {
MapReader { proxy in
MapBase(initialPosition: .amsterdam, initialZoomLevel: 54)
.mapCompass(false)
.mapRender(isAppActive)
}
.ignoresSafeArea()
.onChange(of: scenePhase) { newPhase in
switch newPhase {
case .active:
isAppActive = true
case .background:
isAppActive = false
default:
break
}
}
}
}
info

This is the most basic example of controlling map rendering. Rendering can be toggled on and off at any time based on your app's specific needs, such as pausing rendering when the map is not fully visible or when UI smoothness is a priority, like with animations.