View
extension View-
A modifier that provides an autocomplete component for the user to select a place.
When
showis 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 theonSelectionhandler 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 ViewParameters
filterThe filter to apply to the autocomplete requests from the component.
uiCustomizationThe UI customization to apply to the component.
initialQueryThe initial query to use for the component.
showThe binding for whether the component is shown.
onSelectionThe closure to run when a place is selected.
onErrorThe closure to run when an error occurs.
Return Value
A modified view that displays the component when
showis true. -
Handles analytics events from Places UI Kit components in this view’s subtree.
Attach this modifier to a single component to handle that component’s events, or to a container or app root to handle events from every Places UI Kit component beneath it.
Handlers compose rather than replace each other. When handlers are attached at more than one level of the view hierarchy, each handler receives every event from the components beneath it: the handler closest to the component runs first, followed by the handlers attached higher in the hierarchy.
The handler is called in addition to the component’s default behavior; it cannot cancel or replace that behavior.
Declaration
Swift
@MainActor func onPlaceAnalyticsEvent(_ handler: @escaping @MainActor @Sendable (PlaceAnalyticsEvent) -> Void) -> some ViewParameters
handlerA closure called on the main actor with each event.
Return Value
A view that reports analytics events from Places UI Kit components to
handler. -
A modifier that provides an autocomplete component for the user to select a place.
When
showis 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 theonSelectionhandler 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 ViewParameters
filterThe filter to apply to the autocomplete requests from the component.
uiCustomizationThe UI customization to apply to the component.
initialQueryThe initial query to use for the component.
sessionTokenThe
AutocompleteSessionTokento 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 theonSelectionhandler.showThe binding for whether the component is shown.
onSelectionThe closure to run when a place is selected.
onErrorThe closure to run when an error occurs.
Return Value
A modified view that displays the component when
showis true. -
Adds a content slot to
AdvancedPlaceDetailsCompactView.Important
Only
AdvancedPlaceDetailsCompactViewrenders content slots. Applying this modifier to any other widget, including the basic-tierPlaceDetailsCompactView, 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 ViewParameters
positionThe position of the content slot.
contentA builder for the content to display, given the place shown by the widget.
Return Value
A view that renders the given content at
position.