고급 장소 목록 구성요소
고급 장소 목록 구성요소를 사용하면 장소 목록을 정의하고 표시할 수 있습니다. 장소 세부정보 구성요소에서 지원하는 동일한 ID 집합 (장소 ID, 장소 리소스 이름 또는 위도/경도 좌표)에서 최대 20개의 장소를 나열할 수 있습니다.
가로 또는 세로 목록 표시 중에서 선택할 수 있습니다. 기본 방향은 세로입니다. 각 목록 항목에 간단한 장소 세부정보 카드 및 전체 장소 세부정보 카드와 동일한 정보 및 구성 옵션이 제공됩니다.
AdvancedPlaceListView의 orientation, placeIdentifiers, configuration 매개변수를 사용하여 목록을 만듭니다. 자세한 내용은 예를 참고하세요.
결제
각 목록 요청에 대해 요금이 청구되며 목록의 변경사항은 청구 가능한 새로운 이벤트입니다.
예
이 샘플은 장소 식별자를 기반으로 목록을 만듭니다. configuration 매개변수는 각 목록 항목에 주소, 평점, 유형이 다른 시각적 사양과 함께 표시되도록 지정합니다. 사용자가 각 목록 항목을 즐겨찾기에 추가하거나 즐겨찾기에서 삭제할 수 있도록 기본 작업이 생성됩니다. 각 목록 항목에 대해 모서리 작업이 사용 중지됩니다.
Swift
struct AdvancedPlaceListDemoView: View { private let configuration = AdvancedPlaceListConfiguration( content: [.address(), .rating(), .type()], preferTruncation: true, theme: PlacesMaterialTheme(), attributionPosition: .bottom, mediaSize = .medium, selectable: true ) @State private var placeIdentifiers = [.placeID("ChIJj61dQgK6j4AR4GeTYWZsKWw")] @State private var favoritePlaces: Set<String> = [] var body: some View { AdvancedPlaceListView( orientation: .horizontal, // default is vertical placeIdentifiers: placeIdentifiers, configuration: configuration ) .onLoad { results in for result in results { switch result { case .success(let place) print("place: \(place)") case .failure(let error) print("error: \(error)") } } } .onPlaceSelected { place, index in print("place: \(place)") print("index: \(index)") } .mainActions { place in var actions: [MainPlaceActionElement] = [] let placeID = place.placeID! if self.favoritePlaces.contains(placeID) { actions.append( .action( MainPlaceAction( image: Image(systemName: "heart.fill"), label: "Unfavorite" ) { _ in self.toggleFavorite(placeID) } ) ) } else { actions.append( .action( MainPlaceAction( image: Image(systemName: "heart"), label: "Favorite" ) { _ in self.toggleFavorite(placeID) } ) ) } actions.append(.actionId(.openMap(style: .primary))) return actions } // Ensures that there are no corner actions. .cornerActions { _ in return [] } } func toggleFavorite(_ placeID: String) { if favoritePlaces.contains(placeID) { favoritePlaces.remove(placeID) } else { favoritePlaces.insert(placeID) } } }