iOS için Yerler SDK'sı mevcut Yer Fotoğrafı'nı destekler. Mevcut Yer Fotoğrafı hakkında bilginiz varsa Yer Fotoğrafı'nın yeni sürümü aşağıdaki değişiklikleri yapar:
Yeni bir fiyatlandırma modeli kullanır. Tüm API'lerle ilgili fiyatlandırma bilgilerini iOS için Yerler SDK'sı Fiyatlandırması (Yeni) bölümünde bulabilirsiniz.
Mevcut Yer Fotoğrafı, maksimum 1600 x 1600 piksel boyutunu destekliyordu. Yer Fotoğrafı (Yeni) 4800 x 4800 piksele kadar boyutları destekler.
İstekte bulunmak için yeni
GMSPlacesClient fetchPhotoWithRequest:callback:
yöntemini çağırın.İsteğe iletin:
Maksimum resim boyutu dahil olmak üzere tüm istek parametrelerini tanımlayan yeni
GMSFetchPhotoRequest
sınıfının bir örneği.Yanıtı işlemek için
GMSPlacePhotoMetadataResultCallback
türünde bir geri çağırma.
Her fotoğraf bir
GMSPlacePhotoMetadata
örneğiyle temsil edilir. iOS (Yeni) için Yerler SDK'sıGMSPlacePhotoMetadata
örneği, yeni GMSPlaceAuthorAttribution sınıfıyla temsil edilen yeni birauthorAttribution
alanı içerir.Döndürülen
GMSPlacePhotoMetadata
örneğiattributions
veyaauthorAttribution
içeriyorsa görseli görüntülediğiniz her yerde bu atıfları uygulamanıza eklemeniz gerekir. Atıflar ile ilgili belgeleri inceleyin.
Örnek istek
Aşağıdaki örnek yöntem bir yer kimliği alır ve döndürülen listedeki ilk fotoğrafı alır. 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 } }]; }];