Komponent Zaawansowana lista miejsc
Komponent Zaawansowana lista miejsc umożliwia definiowanie i wyświetlanie listy miejsc. Możesz wyświetlić listę maksymalnie 20 miejsc z tego samego zestawu tożsamości obsługiwanych przez komponent informacji o miejscu (identyfikatory miejsc, nazwy zasobów miejsc lub współrzędne geograficzne).
Możesz wybrać wyświetlanie listy w orientacji poziomej lub pionowej. Domyślna orientacja to pionowa. W przypadku każdego elementu listy dostępne są te same informacje i opcje konfiguracji co w przypadku kart z informacjami o miejscu w wersji kompaktowej i pełnej.
Aby utworzyć listę, użyj interfejsu PlaceActionProvider w AdvancedPlaceListFragment.
Płatności
Opłaty są naliczane za każde żądanie listy, a każda zmiana na liście jest nowym zdarzeniem podlegającym opłacie.
Przykład
Utwórz fragment AdvancedPlaceList
Kotlin
// Initialize first Places.initializeWithNewPlacesApiEnabled(context, API_KEY) // how fragment is created AdvancedPlaceListFragment.newInstance( selectedContent, orientation, R.style.BrandedPlaceDetailsTheme, ) // fragments support the same configurations that PlaceSearchFragment supports fragment.preferTruncation = false fragment.attributionPosition = AttributionPosition.BOTTOM fragment.mediaSize = AdvancedPlaceListFragment.MediaSize.SMALL fragment.selectable = true
Wyświetlanie listy miejsc
Kotlin
// You can use resourceNames or placeIds advancedPlaceListFragment.configureFromPlaceIds(placeIds) advancedPlaceListFragment.configureFromResourceNames(resourceNames) // Alternatively, use coordinates, which are a list of LatLng: advancedPlaceListFragment.configureFromCoordinates(coordinates) // Uses reverse geocoding to get the place
Słuchanie wyników
Kotlin
// Attach the existing PlaceSearchFragmentListener to get notified when places load or are selected from the results list. override fun onAttachFragment(fragment: Fragment) { super.onAttachFragment(fragment) when (fragment) { // Reuse the placeSearchFragmetnListener from the Essentials version is AdvancedPlaceSearchFragment -> fragment.registerListener(placeSearchFragmentListener) // Use placeListFragmentListener, it's functionally identical but with a new name. is AdvancedPlaceListFragment -> fragment.registerListener(advancedPlaceListFragmentListener) } }