Places SDK for iOS supports Place Photo (Legacy) . If you are familiar with Place Photo (Legacy), Place Photo (New) makes the following changes:
-
Uses a new pricing model. For pricing information for all APIs, see Pricing for the Places SDK for iOS (New) .
-
Place Photo (Legacy) supported a maximum photo size of 1600 by 1600 pixels. Place Photo (New) supports sizes up to 4800 by 4800 pixels.
-
To make a request, call the new
GMSPlacesClient fetchPhotoWithRequest:callback:method. -
Pass to the request:
-
An instance of the new
GMSFetchPhotoRequestclass that defines all request parameters, including the max image size. -
A callback of type
GMSPlacePhotoMetadataResultCallbackto handle the response.
-
-
Each photo is represented by a
GMSPlacePhotoMetadatainstance. For Places SDK for iOS (New) theGMSPlacePhotoMetadatainstance contains a newauthorAttributionfield represented by the newGMSPlaceAuthorAttributionclass.If the returned
GMSPlacePhotoMetadatainstance includesattributionsorauthorAttribution, you must include these attributions in your application wherever you display the image. See the documentation on attributions .
Example request
The following example method takes a place ID and gets the first photo in the returned list. You can use this method as a template for the method you will create in your own 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 } }]; }];

