Advanced Place Search component

The Advanced version of the Place Search component offers the same features as Place Search Essentials. It also lets you configure the action buttons of the component and apply search and filtering options to the reviews and media that appear.

Advanced Place Search configuration

Use the AdvancedPlaceSearchFragment to access advanced features.

Configure action buttons

Use the PlaceActionProvider interface of the AdvancedPlaceSearchFragment to define and customize action buttons.

Visual attribution requirements

AdvancedPlace Search view with customized buttons
Place Search result with customized button

Important: You must make it clear to users when a custom action button will share user information with a third party other than Google. See visual attribution requirements.

The example shows a custom image that makes it clear that user information will be sent to "Altostrat".

Apply search and filtering options

Use the SearchMediaOptions and the SearchReviewsOptions interfaces of the AdvancedPlaceSearchFragment to enable search and filtering for media or reviews.

Advanced Place Search examples

Create an AdvancedPlaceSearch fragment

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)


        

Listen to results

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)
    }
}