Zaawansowany komponent Listy miejsc

Zaawansowany komponent Listy miejsc umożliwia definiowanie i wyświetlanie listy miejsc. Możesz wyświetlić maksymalnie 20 miejsc z tego samego zestawu tożsamości obsługiwanych przez komponent Informacje o miejscu (identyfikatory miejsc, nazwy zasobów miejsc lub współrzędne geograficzne).

Możesz wybrać wyświetlanie listy w poziomie lub w pionie. Domyślna orientacja to pionowa. W przypadku każdego elementu listy dostępne są te same informacje i opcje konfiguracji co w przypadku kompaktowych i pełnych kart informacji o miejscu.

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

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)
    }
}