iOS için Yerler SDK'sı (Eski), Yer Adı Otomatik Tamamlama (Eski)'yı destekler. Yer Adı Otomatik Tamamlama (Eski) özelliğini biliyorsanız Otomatik Tamamlama (Yeni) aşağıdaki değişiklikleri yapar:
Yeni bir fiyatlandırma modeli kullanır. Tüm API'lerin fiyatlandırma bilgileri için Kullanım ve faturalandırma başlıklı makaleyi inceleyin.
İstek göndermek için yeni
GMSPlacesClient fetchAutocompleteSuggestionsFromRequest:yöntemini çağırın.İsteğe iletme:
Sorgu ve oturum jetonu gibi tüm istek parametrelerini tanımlayan yeni
GMSAutocompleteRequestsınıfının bir örneği.Yanıtı işlemek için
GMSAutocompleteSuggestionsCallbacktüründe bir geri çağırma.
GMSAutocompleteFiltersınıfı artık şunları yapmanıza olanak tanır:- Sonuçların biçimlendirmesini belirlemek için kullanılan bölge kodunu ayarlayın.
- Sorgunun sıfır tabanlı Unicode karakter kayması olan tahmin kaymasını ayarlayın.
Yanıt, yeni
GMSAutocompleteSuggestionsınıfı tarafından tanımlanır. Bu sınıf, önerileri temsil eden yeni türünGMSAutocompletePlaceSuggestionbir dizi örneğini içerir.Oturum, Yer Ayrıntıları (Yeni) veya Adres Doğrulama'ya yönlendirme ile sona eriyor. Daha fazla bilgi için Otomatik Tamamlama (Yeni) ve oturum fiyatlandırması başlıklı makaleyi inceleyin.
Örnek istek
Otomatik Tamamlama (Yeni) ile bir istekte bulunup GMSAutocompleteRequest örneğindeki tüm parametreleri iletirsiniz:
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.
}
}
}];