高度な場所リスト コンポーネント
高度な場所リスト コンポーネントを使用すると、場所のリストを定義して表示できます。場所の詳細コンポーネントでサポートされている同じ ID セット(場所 ID、場所リソース名、緯度/経度座標)から最大 20 個の場所を一覧表示できます。
リストの表示は横向きと縦向きから選択できます。デフォルトの向きは縦向きです。コンパクトな場所の詳細カードと完全な場所の詳細カードと同じ情報と構成オプションを各リスト項目で使用できます。
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) } }