高度な Place Search コンポーネント
Place Search コンポーネントの Advanced バージョンは、Place Search Essentials と同じ機能を提供します。また、コンポーネントの操作ボタンを設定したり、表示されるレビューやメディアに検索オプションやフィルタ オプションを適用したりすることもできます。
高度なプレイス検索の構成
AdvancedPlaceSearchFragment を使用して上級者向け機能にアクセスします。
操作ボタンを設定する
AdvancedPlaceSearchFragment の PlaceActionProvider インターフェースを使用して、アクション ボタンを定義してカスタマイズします。
視覚的な帰属表示の要件
重要: カスタム アクション ボタンが Google 以外の第三者とユーザー情報を共有する場合、ユーザーにそのことを明確に伝える必要があります。帰属表示の要件をご覧ください。
この例では、ユーザー情報が「Altostrat」に送信されることを明確にするカスタム画像が表示されています。
検索とフィルタリングのオプションを適用する
AdvancedPlaceSearchFragment の SearchMediaOptions インターフェースと SearchReviewsOptions インターフェースを使用して、メディアまたはレビューの検索とフィルタリングを有効にします。
高度な Place Search の例
AdvancedPlaceSearch フラグメントを作成する
Kotlin
// Initialize Places first Places.initializeWithNewPlacesApiEnabled(context, API_KEY) // How the fragment is created AdvancedPlaceSearchFragment.newInstance( selectedContent, orientation, R.style.BrandedPlaceDetailsTheme, ) // Fragment supports the same configs that PlaceSearchFragment supported fragment.preferTruncation = false fragment.attributionPosition = AttributionPosition.BOTTOM fragment.selectable = true
検索を実行する
Kotlin
// Performing a search works the same as with a regular placeSearchFragment. advancedPlaceSearchFragment.configureFromSearchByTextRequest(searchByTextRequest) advancedPlaceSearchFragment.configureFromSearchNearbyRequest(searchNearbyRequest)
結果を聞く
Kotlin
// attach the existing PlaceSearchFragmentListener to get notified about 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, its functionally identical but with a new name. is AdvancedPlaceListFragment -> fragment.registerListener(advancedPlaceListFragmentListener) } }