iOS için Yerler SDK'sı, Yer Fotoğrafı (Eski)'nı destekler. Eski Yer Fotoğrafı'nı kullanıyorsanız Yeni Yer Fotoğrafı'nda aşağıdaki değişiklikler yapılır:
Yeni bir fiyatlandırma modeli kullanır. Tüm API'lerin fiyatlandırma bilgileri için iOS için Yerler SDK'sı (Yeni) Fiyatlandırması başlıklı makaleyi inceleyin.
Yer Fotoğrafı (Eski) özelliği, maksimum 1.600 x 1.600 piksel boyutundaki fotoğrafları destekliyordu. Yer Fotoğrafı (Yeni) 4.800 x 4.800 piksele kadar olan boyutları destekler.
İstek göndermek için yeni
GMSPlacesClient fetchPhotoWithRequest:callback:yöntemini çağırın.İsteğe iletme:
Maksimum resim boyutu da dahil olmak üzere tüm istek parametrelerini tanımlayan yeni
GMSFetchPhotoRequestsınıfının bir örneği.Yanıtı işlemek için
GMSPlacePhotoMetadataResultCallbacktüründe bir geri çağırma.
Her fotoğraf bir
GMSPlacePhotoMetadataörneğiyle temsil edilir. iOS için Yerler SDK'sında (Yeni)GMSPlacePhotoMetadataörnek, yeniauthorAttributionalanını içerir. Bu alan, yeniGMSPlaceAuthorAttributionsınıfıyla temsil edilir.Döndürülen
GMSPlacePhotoMetadataörneğiattributionsveyaauthorAttributioniçeriyorsa bu ilişkilendirmeleri, resmi uygulamanızda gösterdiğiniz her yere eklemeniz gerekir. İlişkilendirmeler ile ilgili dokümanları inceleyin.
Örnek istek
Aşağıdaki örnek yöntem, bir yer kimliği alır ve döndürülen listedeki ilk fotoğrafı elde eder. Bu yöntemi, kendi uygulamanızda oluşturacağınız yöntem için şablon olarak kullanabilirsiniz.
Swift
// A hotel in Saigon with an attribution. let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs" // Request list of photos for a place placesClient.lookUpPhotos(forPlaceID: placeID) { (photos, error) in guard let photoMetadata: GMSPlacePhotoMetadata = photos?.results[0] else { return } // Request individual photos in the response list let fetchPhotoRequest = GMSFetchPhotoRequest(photoMetadata: photoMetadata, maxSize: CGSizeMake(4800, 4800)) self.client.fetchPhoto(with: fetchPhotoRequest, callback: { (photoImage: UIImage?, error: Error?) in guard let photoImage, error == nil else { print("Handle photo error: ") return } print("Display photo Image: ") } ) }
Objective-C
// A hotel in Saigon with an attribution. NSString *placeID = @"ChIJV4k8_9UodTERU5KXbkYpSYs"; [placesClient lookUpPhotosForPlaceID:placeID callback: ^(GMSPlacePhotoMetadataList *list, NSError *error) { GMSPlacePhotoMetadata *photoMetadata = [list results][0]; // Request individual photos in the response list GMSFetchPhotoRequest *fetchPhotoRequest = [[GMSFetchPhotoRequest alloc] initWithPhotoMetadata:photoMetadata maxSize:CGSizeMake(4800, 4800)]; [placesClient fetchPhotoWithRequest:fetchPhotoRequest callback: ^(UIImage *_Nullable photoImage, NSError *_Nullable error) { if (error == nil) { // Display photo } }]; }];