高度な場所リスト コンポーネント
高度な場所リスト コンポーネントを使用すると、場所のリストを定義して表示できます。場所の詳細コンポーネントでサポートされている同じ ID セット(場所 ID、場所リソース名、緯度/経度座標)から最大 20 個の場所をリスト表示できます。
リストの表示は、横向きまたは縦向きを選択できます。デフォルトの向きは縦向きです。コンパクトな Place Details カードや完全な Place Details カードと同じ情報と構成オプションを、各リストアイテムで使用できます。
AdvancedPlaceListFragment の PlaceActionProvider インターフェースを使用して、リストを作成します。
課金
リスト リクエストごとに課金されます。リストを変更するたびに、新しい課金対象イベントが発生します。
例
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
場所リストを表示する
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
結果をリッスンする
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) } }