Utilise un nouveau modèle de tarification. Pour obtenir des informations sur les tarifs de toutes les API, consultez Tarifs du SDK Places pour iOS (nouveau).
L'ancienne fonctionnalité Photo de lieu acceptait une taille maximale de 1 600 x 1 600 pixels. Place Photo (New)
accepte les tailles jusqu'à 4 800 x 4 800 pixels.
Si l'instance GMSPlacePhotoMetadata renvoyée inclut attributions ou authorAttribution, vous devez inclure ces attributions dans votre application partout où vous affichez l'image. Consultez la documentation sur les attributions.
Exemple de requête
L'exemple de méthode suivant accepte un ID de lieu et obtient la première photo de la liste renvoyée. Vous pouvez utiliser cette méthode comme modèle pour la méthode que vous allez créer dans votre propre application.
Swift
// 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}}];}];
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/31 (UTC).
[null,null,["Dernière mise à jour le 2025/08/31 (UTC)."],[],[],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```"]]