Place Autocomplete로 이전 (신규)

iOS용 Places SDK는 기존 Place Autocomplete. 기존의 Place Autocomplete은 Place Autocomplete 다음과 같이 변경합니다.

요청 예시

Place Autocomplete (신규)를 사용하면 요청을 생성하고 GMSAutocompleteRequest 인스턴스의 모든 매개변수를 전달합니다.

Swift

let token = GMSAutocompleteSessionToken()

let northEastBounds = CLLocationCoordinate2DMake(37.38816277477739, -122.08813770258874)
let southWestBounds = CLLocationCoordinate2DMake(37.39580487866437, -122.07702325966572)

let filter = GMSAutocompleteFilter()
filter.types = [kGMSPlaceTypeRestaurant]
filter.locationBias = GMSPlaceRectangularLocationOption(northEastBounds, southWestBounds)

let request = GMSAutocompleteRequest(query:"Sicilian piz")
request.filter = filter
request.sessionToken = token
GMSPlacesClient.shared().fetchAutocompleteSuggestions(from: request, callback: { results, error in
   // Handle response
})

Objective-C

  CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(37.38816277477739, -122.08813770258874);
  CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(37.39580487866437, -122.07702325966572);

  GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init];
  filter.types = @[ kGMSPlaceTypeRestaurant ];
  filter.locationBias = GMSPlaceRectangularLocationOption(northEast, southWest);
  GMSAutocompleteRequest *request = [[GMSAutocompleteRequest alloc] initWithQuery:@"Sicilian piz"];
  request.sessionToken = token;
  request.filter = filter;

  [[GMSPlacesClient sharedClient] fetchAutocompleteSuggestionsFromRequest:request callback:^(NSArray<GMSAutocompleteSuggestion *> * results, NSError * error){
    // Handle response
    for (GMSAutocompleteSuggestion *suggestion in results) {
      if (suggestion.placeSuggestion) {
        // Show place suggestion data.
      }
    }
  }];