Map View Components
The SDK exposes provider-specific SwiftUI views. Choose the view that matches the provider module used by the screen.
| Provider | View state | SwiftUI view |
|---|---|---|
| Google Maps | GoogleMapViewState | GoogleMapView |
| Mapbox | MapboxViewState | MapboxMapView |
| MapKit | MapKitViewState | MapKitMapView |
| MapLibre | MapLibreViewState | MapLibreMapView |
| ArcGIS | ArcGISMapViewState | ArcGISMapView |
Each view accepts a state object, optional map event handlers, and a @MapViewContentBuilder content closure.
Use a provider map view as the root container for map overlays on that screen. The map view is responsible for creating and updating the native SDK view; the content closure describes the MapConductor overlays that should be synchronized onto it.
import SwiftUIimport MapConductorCoreimport MapConductorForGoogleMaps
struct ContentView: View { @StateObject private var mapViewState = GoogleMapViewState( cameraPosition: MapCameraPosition( position: GeoPoint(latitude: 35.6812, longitude: 139.7671), zoom: 13 ) )
var body: some View { GoogleMapView( state: mapViewState, onMapClick: { point in print("Map clicked at \(point)") }, onCameraMoveEnd: { camera in print("Camera ended at zoom \(camera.zoom)") } ) { Marker( position: GeoPoint(latitude: 35.6812, longitude: 139.7671), icon: DefaultMarkerIcon(label: "T") )
Circle( center: GeoPoint(latitude: 35.6812, longitude: 139.7671), radiusMeters: 500, fillColor: UIColor.red.withAlphaComponent(0.2) ) } .ignoresSafeArea() }}Content Builder Items
Section titled “Content Builder Items”The current MapViewContentBuilder accepts these overlay items from MapConductorCore:
MarkerInfoBubblePolylinePolygonCircleGroundImageRasterLayerForArray
Optional modules add more items, such as HeatmapOverlay from MapConductorHeatmap and MarkerClusterGroup from MapConductorMarkerCluster.
Use ForArray when rendering a dynamic collection of overlays from state. Give overlays stable id values where available so the SDK can update existing native objects instead of replacing them unnecessarily.
Event Handlers
Section titled “Event Handlers”Map handlers are initializer parameters:
onMapLoadedonMapClickonCameraMoveStartonCameraMoveonCameraMoveEnd
Pass these handlers directly when constructing the provider map view.
Provider Switching
Section titled “Provider Switching”The map view type and state type must match:
@StateObject private var state = MapboxViewState( cameraPosition: MapCameraPosition( position: GeoPoint(latitude: 35.6812, longitude: 139.7671), zoom: 13 ))
MapboxMapView(state: state) { Marker(position: GeoPoint(latitude: 35.6812, longitude: 139.7671))}Overlay declarations such as Marker, Circle, and Polyline are shared. Provider-specific behavior belongs in provider setup, provider design types, or native SDK access through getMapViewHolder().
Layout Notes
Section titled “Layout Notes”Provider views are normal SwiftUI views. Apply SwiftUI layout modifiers to the provider map view itself:
GoogleMapView(state: mapViewState) { Marker(position: tokyoStation)}.frame(height: 320).clipShape(RoundedRectangle(cornerRadius: 8))Keep long-running data loading outside the content closure. The closure should describe current overlay state, not perform network requests or expensive coordinate processing.