Hello, I want to filter the results of prompts for a specific country (Russia), but Googl Place API for Android in the class AutocompleteFilter is only from constant fields, in which you can filter only the type.

Can you please tell me how to filter the results of prompts for Russia and the address

    1 answer 1

    The Places.GeoDataApi.getAutocompletePredictions method, Places.GeoDataApi.getAutocompletePredictions addition to AutocompleteFilter , also has LatLngBounds , which allows you to filter results by coordinates.

    The area turns out something like this:

     LatLngBounds latLngBounds = LatLngBounds.builder() .include(new LatLng(60.137332, 29.9322964)) .include(new LatLng(60.197112, 30.234420)) .include(new LatLng(60.120908, 30.579664)) .build(); 

    But "inside" he will get two points from this to limit the area - with the minimum coordinates and the maximum.

    Or transfer them immediately to the constructor:

     LatLngBounds latLngBounds = new LatLngBounds(new LatLng(60.117332, 29.9322964), new LatLng(60.197112, 30.234420)); 

    Which is the same.

    • If you restrict by coordinates, then the country is not rectangular, the desired area will either be larger than the country, or will not capture some areas - Evgeny Suetin
    • one
      Yes, but the API does not offer anything better. As a crutch option - always in the beginning of the address in the address line to substitute "Russia," - z17