GooglePlacesSwift Framework Reference

View

extension View
  • A modifier that provides an autocomplete component for the user to select a place.

    When show is set to true, the user will be brought to a fullscreen view where they can select a place. As the user types, the component returns suggestions for places such as businesses, addresses, and points of interest. When the user selects a place, the component calls the onSelection handler with the selected place, and closes the fullscreen view.

    Declaration

    Swift

    @MainActor
    func basicPlaceAutocomplete(filter: AutocompleteFilter? = nil, uiCustomization: AutocompleteUICustomization = AutocompleteUICustomization(), initialQuery: String = "", show: Binding<Bool>, onSelection: @escaping (Place) -> Void, onError: @escaping (PlacesError) -> Void) -> some View
    

    Parameters

    filter

    The filter to apply to the autocomplete requests from the component.

    uiCustomization

    The UI customization to apply to the component.

    initialQuery

    The initial query to use for the component.

    show

    The binding for whether the component is shown.

    onSelection

    The closure to run when a place is selected.

    onError

    The closure to run when an error occurs.

    Return Value

    A modified view that displays the component when show is true.

  • A modifier that provides an autocomplete component for the user to select a place.

    When show is set to true, the user will be brought to a fullscreen view where they can select a place. As the user types, the component returns suggestions for places such as businesses, addresses, and points of interest. When the user selects a place, the component calls the onSelection handler with the selected place, and closes the fullscreen view.

    Declaration

    Swift

    @MainActor
    func placeAutocomplete(filter: AutocompleteFilter? = nil, uiCustomization: AutocompleteUICustomization = AutocompleteUICustomization(), initialQuery: String = "", sessionToken: AutocompleteSessionToken? = nil, show: Binding<Bool>, onSelection: @escaping (AutocompletePlaceSuggestion, AutocompleteSessionToken) -> Void, onError: @escaping (PlacesError) -> Void) -> some View
    

    Parameters

    filter

    The filter to apply to the autocomplete requests from the component.

    uiCustomization

    The UI customization to apply to the component.

    initialQuery

    The initial query to use for the component.

    sessionToken

    The AutocompleteSessionToken to associate requests with a billing session. A unique session token should be provided each time the component is shown. If no session token is provided, one will be created internally and returned in the onSelection handler.

    show

    The binding for whether the component is shown.

    onSelection

    The closure to run when a place is selected.

    onError

    The closure to run when an error occurs.

    Return Value

    A modified view that displays the component when show is true.

  • Adds a content slot to AdvancedPlaceDetailsCompactView.

    Important

    Only AdvancedPlaceDetailsCompactView renders content slots. Applying this modifier to any other widget, including the basic-tier PlaceDetailsCompactView, has no effect: the content is not rendered, and a warning is written to the console.

    Declaration

    Swift

    @MainActor
    func placeDetailsCompactContentSlot(position: PlaceDetailsCompactSlotPosition, @ViewBuilder content: @escaping @MainActor @Sendable (Place) -> some View) -> some View
    

    Parameters

    position

    The position of the content slot.

    content

    A builder for the content to display, given the place shown by the widget.

    Return Value

    A view that renders the given content at position.