GooglePlacesSwift Framework Reference

PlaceMarker

@MainActor
struct PlaceMarker
extension PlaceMarker : Sendable, SendableMetatype, View

A SwiftUI View displaying a place marker (with an optional icon and text such as rating, price range, open status, or custom text).

Fetches place details asynchronously using the provided PlaceIdentifier and renders the corresponding speech-bubble or custom marker when required attribute data is available.

  • The type of view representing the body of this view.

    When you create a custom view, Swift infers this type from your implementation of the required View/body-swift.property property.

    Declaration

    Swift

    typealias Body = some View
  • The content and behavior of the view.

    When you implement a custom view, you must implement a computed body property to provide the content for your view. Return a view that’s composed of built-in views that SwiftUI provides, plus other composite views that you’ve already defined:

    struct MyView: View {
        var body: some View {
            Text("Hello, World!")
        }
    }
    

    For more information about composing views and a view hierarchy, see doc:Declaring-a-Custom-View.

    Declaration

    Swift

    @MainActor
    @preconcurrency
    var body: some View { get }
  • Visual styling options for customizing the marker.

    Declaration

    Swift

    @MainActor
    var configuration: PlaceMarkerConfiguration
  • The identifier specifying the place to fetch and display.

    Declaration

    Swift

    @MainActor
    let identifier: PlaceIdentifier
  • Declaration

    Swift

    @MainActor
    init(identifier: PlaceIdentifier, markerIcon: MarkerIcon = .none, markerText: MarkerText? = nil, configuration: PlaceMarkerConfiguration = PlaceMarkerConfiguration())
  • The marker icon variant displayed by the marker.

    Declaration

    Swift

    @MainActor
    let markerIcon: MarkerIcon
  • The optional text displayed inside the marker.

    Declaration

    Swift

    @MainActor
    let markerText: MarkerText?
  • Adds a callback to be called when the place details are loaded.

    Declaration

    Swift

    @MainActor
    func onLoad(_ callback: @escaping (Result<Place, PlacesError>) -> Void) -> PlaceMarker

    Parameters

    callback

    The callback to be called when the place results are loaded.

    Return Value

    The PlaceMarker with the callback added.

  • Adds an action to perform when the marker is tapped by the user.

    Declaration

    Swift

    @MainActor
    func onTap(_ action: @escaping (String) -> Void) -> PlaceMarker

    Parameters

    action

    The closure to execute on tap, receiving the place ID string.

    Return Value

    A modified PlaceMarker with the tap action attached.