diff --git a/.DS_Store b/.DS_Store index 99b0581..6e2b691 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index e7c1efb..c055661 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ [![alt text][InstagramIcon]][Instagram] [![alt text][TelegramIcon]][Telegram] +### #185 Filter Google Places Autocomplete +![alt text](/screenshots/FilterGooglePlacesAutocomplete.png) + ### #184 String Extension JoinToString ![alt text](/screenshots/JoinToString.png) diff --git a/codes/FilterGooglePlacesAutocomplete.kt.kt b/codes/FilterGooglePlacesAutocomplete.kt.kt new file mode 100644 index 0000000..4850098 --- /dev/null +++ b/codes/FilterGooglePlacesAutocomplete.kt.kt @@ -0,0 +1,40 @@ +/* + * Filtering Google Places Autocomplete Results + */ + +/* + * Field list to receive from the place instances + */ +val fields = listOf( + Place.Field.NAME, + Place.Field.ADDRESS, + Place.Field.LAT_LNG +) + +/* + * Rectangular area bounds to filter place results + */ +val bounds = RectangularBounds.newInstance( + LatLng(-33.880490, 151.184363), + LatLng(-33.858754, 151.229596) +) + +val placesBuilder = Autocomplete.IntentBuilder( + AutocompleteActivityMode.OVERLAY, + fields +) + +/* + * Filter places result by area bounds + */ +placesBuilder.setLocationBias(bounds) + +/* + * Filter places result by country code + */ +placesBuilder.setCountry("TR") + +/* + * Start places search intent + */ +startActivityForResult(placesBuilder.build(context), 1000) \ No newline at end of file diff --git a/screenshots/FilterGooglePlacesAutocomplete.png b/screenshots/FilterGooglePlacesAutocomplete.png new file mode 100644 index 0000000..58ffef0 Binary files /dev/null and b/screenshots/FilterGooglePlacesAutocomplete.png differ