Advanced Place List コンポーネント
Advanced Place List コンポーネントを使用すると、場所のリストを定義して表示できます。Place Details コンポーネントでサポートされている同じ 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) } }