Komponent Zaawansowana lista miejsc

Komponent Zaawansowana lista miejsc umożliwia zdefiniowanie i wyświetlenie listy miejsc. Możesz wyświetlić maksymalnie 20 miejsc z tego samego zestawu tożsamości obsługiwanych przez komponent Szczegóły miejsca (identyfikatory miejsc, nazwy zasobów miejsc lub współrzędne geograficzne).

Możesz wybrać wyświetlanie listy w pionie lub w poziomie. Domyślna orientacja to pionowa. Każdy element listy zawiera te same informacje i opcje konfiguracji co karty z kompaktowymi i pełnymi informacjami o miejscu.

Aby utworzyć listę, użyj interfejsu PlaceActionProvider 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

Tworzenie fragmentu 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

Odsłuchiwanie 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)
    }
}