Skip to content

Map View Components

The SDK exposes provider-specific SwiftUI views. Choose the view that matches the provider module used by the screen.

ProviderView stateSwiftUI view
Google MapsGoogleMapViewStateGoogleMapView
MapboxMapboxViewStateMapboxMapView
MapKitMapKitViewStateMapKitMapView
MapLibreMapLibreViewStateMapLibreMapView
ArcGISArcGISMapViewStateArcGISMapView

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 SwiftUI
import MapConductorCore
import 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()
}
}

The current MapViewContentBuilder accepts these overlay items from MapConductorCore:

  • Marker
  • InfoBubble
  • Polyline
  • Polygon
  • Circle
  • GroundImage
  • RasterLayer
  • ForArray

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.

Map handlers are initializer parameters:

  • onMapLoaded
  • onMapClick
  • onCameraMoveStart
  • onCameraMove
  • onCameraMoveEnd

Pass these handlers directly when constructing the provider map view.

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().

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.