Skip to main content

Center Map

Last updated: April 24, 2026 | 2 minutes read

This example demonstrates how to use GEMKit in a SwiftUI application to programmatically center the map on a specific coordinate.

Check the full implementation on GitHub.

Initial Map View
Map View after centering

Centering the Map

MapReader exposes a proxy that provides access to the map's camera control. Tapping the toolbar button calls proxy.centerOn(coordinates:zoomLevel:duration:) to animate the camera to Paris:

ContentView.swiftView on GitHub
struct ContentView: View {

let location = CoordinatesObject.coordinates(
withLatitude: 48.840827,
longitude: 2.381899)

var body: some View {
MapReader { proxy in
MapBase()
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("", systemImage: "target") {

proxy.centerOn(coordinates: location, zoomLevel: 50, duration: 1000)
}
.buttonStyle(.borderedProminent)
}
}
}
.ignoresSafeArea()
}
}