// A hotel in Saigon with an attribution.letplaceID="ChIJV4k8_9UodTERU5KXbkYpSYs"// Request list of photos for a placeplacesClient.lookUpPhotos(forPlaceID:placeID){(photos,error)inguardletphotoMetadata:GMSPlacePhotoMetadata=photos?.results[0]else{return}// Request individual photos in the response listletfetchPhotoRequest=GMSFetchPhotoRequest(photoMetadata:photoMetadata,maxSize:CGSizeMake(4800,4800))self.client.fetchPhoto(with:fetchPhotoRequest,callback:{(photoImage:UIImage?,error:Error?)inguardletphotoImage,error==nilelse{print("Handle photo error: ")return}print("Display photo Image: ")})}
Objective-C
// A hotel in Saigon with an attribution.NSString*placeID=@"ChIJV4k8_9UodTERU5KXbkYpSYs";[placesClientlookUpPhotosForPlaceID:placeIDcallback:^(GMSPlacePhotoMetadataList*list,NSError*error){GMSPlacePhotoMetadata*photoMetadata=[listresults][0];// Request individual photos in the response listGMSFetchPhotoRequest*fetchPhotoRequest=[[GMSFetchPhotoRequestalloc]initWithPhotoMetadata:photoMetadatamaxSize:CGSizeMake(4800,4800)];[placesClientfetchPhotoWithRequest:fetchPhotoRequestcallback:^(UIImage*_NullablephotoImage,NSError*_Nullableerror){if(error==nil){// Display photo}}];}];
[null,null,["最后更新时间 (UTC):2025-08-31。"],[],[],null,["# Migrate to Place Photo (New)\n\n\u003cbr /\u003e\n\n| This feature requires that you enable Places API (New), the next generation of the Places API. For more information, see [Enable APIs](/maps/documentation/places/ios-sdk/legacy/cloud-setup#enabling-apis).\n\n\u003cbr /\u003e\n\nPlaces SDK for iOS supports\n[Place Photo (Legacy)](/maps/documentation/places/ios-sdk/photos).\nIf you are familiar with Place Photo (Legacy),\n[Place Photo (New)](/maps/documentation/places/ios-sdk/place-photos)\nmakes the following changes:\n\n- Uses a new pricing model. For pricing information for all APIs, see\n [Pricing for the Places SDK for iOS (New)](/maps/documentation/places/ios-sdk/usage-and-billing#pricing-new).\n\n- Place Photo (Legacy) supported a maximum photo\n size of 1600 by 1600 pixels. Place Photo (New)\n supports sizes up to 4800 by 4800 pixels.\n\n- To make a request, call the new [`GMSPlacesClient\n fetchPhotoWithRequest:callback:`](/maps/documentation/places/ios-sdk/legacy/reference/objc/Classes/GMSPlacesClient#-fetchphotowithrequest:callback:)\n method.\n\n- Pass to the request:\n\n - An instance of the new\n [`GMSFetchPhotoRequest`](/maps/documentation/places/ios-sdk/legacy/reference/objc/Classes/GMSFetchPhotoRequest)\n class that defines all request parameters, including the max image size.\n\n - A callback of type\n [`GMSPlacePhotoMetadataResultCallback`](/maps/documentation/places/ios-sdk/reference/objc/Type-Definitions#/c:GMSPlacesClient.h@T@GMSPlacePhotoMetadataResultCallback)\n to handle the response.\n\n- Each photo is represented by a\n [`GMSPlacePhotoMetadata`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacePhotoMetadata)\n instance. For Places SDK for iOS (New) the `GMSPlacePhotoMetadata`\n instance contains a new\n [`authorAttribution`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacePhotoMetadata#authorattributions)\n field represented by the new\n [`GMSPlaceAuthorAttribution`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlaceAuthorAttribution)\n class.\n\n If the returned `GMSPlacePhotoMetadata` instance includes\n [`attributions`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacePhotoMetadata#attributions)\n or `authorAttribution`, you must include these attributions in your\n application wherever you display the image. See the documentation on\n [attributions](/maps/documentation/places/ios-sdk/policies#other_attribution_requirements).\n\n### Example request\n\nThe following example method takes a place ID and gets the first photo in the\nreturned list. You can use this method as a template for the method you will\ncreate in your own app. \n\n### Swift\n\n```swift\n// A hotel in Saigon with an attribution.\nlet placeID = \"ChIJV4k8_9UodTERU5KXbkYpSYs\"\n\n// Request list of photos for a place\nplacesClient.lookUpPhotos(forPlaceID: placeID) { (photos, error) in\n\n guard let photoMetadata: GMSPlacePhotoMetadata = photos?.results[0] else {\n return }\n\n // Request individual photos in the response list\n let fetchPhotoRequest = GMSFetchPhotoRequest(photoMetadata: photoMetadata, maxSize: CGSizeMake(4800, 4800))\n self.client.fetchPhoto(with: fetchPhotoRequest, callback: {\n (photoImage: UIImage?, error: Error?) in\n guard let photoImage, error == nil else {\n print(\"Handle photo error: \")\n return }\n print(\"Display photo Image: \")\n }\n )\n}\n```\n\n### Objective-C\n\n```objective-c\n// A hotel in Saigon with an attribution.\nNSString *placeID = @\"ChIJV4k8_9UodTERU5KXbkYpSYs\";\n\n[placesClient lookUpPhotosForPlaceID:placeID callback: ^(GMSPlacePhotoMetadataList *list, NSError *error) {\n GMSPlacePhotoMetadata *photoMetadata = [list results][0];\n\n // Request individual photos in the response list\n GMSFetchPhotoRequest *fetchPhotoRequest = [[GMSFetchPhotoRequest alloc] initWithPhotoMetadata:photoMetadata maxSize:CGSizeMake(4800, 4800)];\n [placesClient fetchPhotoWithRequest:fetchPhotoRequest callback: ^(UIImage *_Nullable photoImage, NSError *_Nullable error) {\n if (error == nil) {\n // Display photo\n }\n }];\n}];\n```"]]