Esegui la migrazione a Place Photo (novità)

L'SDK Places per iOS supporta l'attuale foto del luogo. Se hai dimestichezza con la foto del luogo esistente, la nuova versione di Place Photo apporta le seguenti modifiche:

Esempio di richiesta

Il seguente metodo di esempio utilizza un ID luogo e ottiene la prima foto nell'elenco dei risultati restituiti. Puoi utilizzare questo metodo come modello per il metodo che creerai nella tua app.

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