How to set “Types” in Google Place PlacePicker in Android?

南笙酒味 提交于 2019-12-01 03:58:24

Currently it seems not to be possible. There is an open feature request, however. Please star it.

Dato' Sapik

Apparently right now, android have documentation to do some filtering using AutocompleteFilter class. The documentation of Place Autocomplete

example of usage :

//set boundary on build place picker fragment
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
builder.setLatLngBounds(bounds);

 //set filter type by country 'malaysia'
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
    .setTypeFilter(1013) //set point of interest
    .setCountry("MY")
    .build();

try {
    Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
        .setFilter(typeFilter)
        .build(MainActivity.this);

    startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);        
} catch (GooglePlayServicesRepairableException e) {
    // TODO: Handle the error.
} catch (GooglePlayServicesNotAvailableException e) {
    // TODO: Handle the error.
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!