คอมโพเนนต์การค้นหาสถานที่ขั้นสูง
คอมโพเนนต์การค้นหาสถานที่เวอร์ชันขั้นสูงมีฟีเจอร์เหมือนกับ Place Search Essentials นอกจากนี้ ยังช่วยให้คุณกำหนดค่าปุ่มการทำงานของคอมโพเนนต์ รวมถึงใช้ตัวเลือกการค้นหาและการกรองกับรีวิวและสื่อที่ปรากฏได้ด้วย
การกำหนดค่าการค้นหาสถานที่ขั้นสูง
ใช้AdvancedPlaceSearchFragmentเพื่อเข้าถึงฟีเจอร์ขั้นสูง
กำหนดค่าปุ่มดำเนินการ
ใช้PlaceActionProviderอินเทอร์เฟซของ AdvancedPlaceSearchFragment เพื่อกำหนดและปรับแต่งปุ่มดำเนินการ
ข้อกำหนดในการระบุแหล่งที่มาด้วยภาพ
สำคัญ: คุณต้องแจ้งให้ผู้ใช้ทราบอย่างชัดเจนเมื่อปุ่มการดำเนินการที่กำหนดเองจะแชร์ข้อมูลผู้ใช้กับบุคคลที่สามที่ไม่ใช่ Google ดูข้อกำหนดในการระบุแหล่งที่มาด้วยภาพ
ตัวอย่างแสดงรูปภาพที่กำหนดเองซึ่งระบุอย่างชัดเจนว่าจะมีการส่งข้อมูลผู้ใช้ไปยัง "Altostrat"
ใช้ตัวเลือกการค้นหาและการกรอง
ใช้SearchMediaOptionsและอินเทอร์เฟซ SearchReviewsOptions ของ AdvancedPlaceSearchFragment เพื่อเปิดใช้การค้นหาและการกรองสื่อหรือรีวิว
ตัวอย่างการค้นหาสถานที่ขั้นสูง
สร้างส่วนย่อย 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) } }