Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit google autocomplete to City and Country only iOS Swift

I have implemented the google AutoComplete function to my app. i want to make sure those autocompletes only for Location, Administrative Area and Country. not roads or any other places. can we do that?

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,
};

This can be achieve by editing this header file right? but i tried removing some of them. but still works same.

like image 554
Im Batman Avatar asked Nov 12 '15 06:11

Im Batman


1 Answers

You could limit the search results

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

using the above code to restrict result to UK and only get City results.

like image 81
Ankahathara Avatar answered Sep 17 '22 18:09

Ankahathara