Limit google autocomplete in City and Country only to iOS Swift

I have applied Google autocomplete function for my application. I want to make sure that these auto-complete are intended only for location, administrative area and country. not roads or other places. we can do this?

typedef NS_ENUM(NSInteger, GMSPlacesAutocompleteTypeFilter) { /** * All results. */ kGMSPlacesAutocompleteTypeFilterNoFilter, /** * Geeocoding results, as opposed to business results. */ kGMSPlacesAutocompleteTypeFilterGeocode, /** * Geocoding results with a precise address. */ kGMSPlacesAutocompleteTypeFilterAddress, /** * Business results. */ kGMSPlacesAutocompleteTypeFilterEstablishment, /** * Results that match the following types: * "locality", * "sublocality" * "postal_code", * "country", * "administrative_area_level_1", * "administrative_area_level_2" */ kGMSPlacesAutocompleteTypeFilterRegion, /** * Results that match the following types: * "locality", * "administrative_area_level_3" */ kGMSPlacesAutocompleteTypeFilterCity, }; 

Can this be achieved by editing this header file correctly? but I tried to remove some of them. but still works.

+5
source share
2 answers

After searching for a while. I have found a solution. I thought there might be a conflict over Objective-C headers.

  let filter = GMSAutocompleteFilter() filter.type = GMSPlacesAutocompleteTypeFilter.City 

+1
source

You can limit your search results.

 let filter = GMSAutocompleteFilter() filter.type = .City filter.country = "uk" 

using the code above to limit the result in the UK and only get city results.

+6
source

Source: https://habr.com/ru/post/1235755/


All Articles