Требуется маскирование полей. Необходимо указать, какие поля должны быть возвращены в ответе. Списка возвращаемых полей по умолчанию нет. Если этот список не указан, методы вернут ошибку.
Ответ содержит экземпляр GMSPlace с информацией о месте. Значения свойства types экземпляра GMSPlace теперь определяются таблицами A и B.
Экземпляр GMSPlace ответа содержит новое свойство reviews типа GMSPlaceReview . Когда ваше приложение отображает информацию, полученную из экземпляра GMSPlace , такую как фотографии и отзывы, оно также должно отображать необходимые атрибуции.
Более подробную информацию см. в документации по атрибуции .
Экземпляр ответа GMSPlace содержит следующие функции-члены:
isOpen вычисляет, открыто ли место в указанное время.
isOpenAtDate вычисляет, открыто ли место в указанную дату.
Эти функции доступны только при включении Places SDK для iOS . Они недоступны при включении Places SDK для iOS (новый) . Подробнее см. в разделе «Выбор версии SDK» .
Пример запроса
При использовании Place Details (New) вы делаете запрос и передаете все параметры в экземпляре GMSFetchPlaceRequest . В этом примере также используется маска поля, поэтому ответ включает только отображаемое имя и URL веб-сайта места:
Быстрый
// A hotel in Saigon with an attribution.letplaceID="ChIJV4k8_9UodTERU5KXbkYpSYs"// Specify the place data types to return.letfields=[GMSPlaceProperty.name,GMSPlaceProperty.website].map{$0.rawValue}// Create the GMSFetchPlaceRequest instance.letfetchPlaceRequest=GMSFetchPlaceRequest(placeID:placeID,placeProperties:fields,sessionToken:nil)client.fetchPlaceWithRequest(fetchPlaceRequest:fetchPlaceRequest,callback:{(place:GMSPlace?,error:Error?)inguardletplace,error==nilelse{return}print("Place found: \(String(describing:place.name))")})
Objective-C
// A hotel in Saigon with an attribution.NSString*placeID=@"ChIJV4k8_9UodTERU5KXbkYpSYs";// Specify the place data types to return.NSArray<NSString*>*fields=@[GMSPlacePropertyName,GMSPlacePropertyWebsite];// Create the GMSFetchPlaceRequest instance.GMSFetchPlaceRequest*fetchPlaceRequest=[[GMSFetchPlaceRequestalloc]initWithPlaceID:placeIDplaceProperties:fieldssessionToken:nil];[placesClientfetchPlaceWithRequest:fetchPlaceRequestcallback:^(GMSPlace*_Nullableplace,NSError*_Nullableerror){if(error!=nil){NSLog(@"An error occurred %@",[errorlocalizedDescription]);return;}else{NSLog(@"Place Found: %@",place.name);NSLog(@"The place URL: %@",place.website);}}];
[null,null,["Последнее обновление: 2025-08-29 UTC."],[],[],null,["# Migrate to Place Details (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 Details (Legacy)](/maps/documentation/places/ios-sdk/place-details).\nIf you are familiar with Places SDK for iOS (Legacy),\n[Place Details (New)](/maps/documentation/places/ios-sdk/details-place)\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- Field masking is required. You must specify which fields you want returned\n in the response. There is no default list of returned fields. If you omit\n this list, the methods return an error.\n\n- To make a request, call the new\n [`GMSPlacesClient fetchPlaceWithRequest:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-fetchplacewithrequest:callback:)\n method.\n\n- Pass to the request:\n\n - An instance of the new\n [`GMSFetchPlaceRequest`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSFetchPlaceRequest)\n class that defines all request parameters, such as the place ID and\n session token.\n\n - A callback of type\n [`GMSPlaceResultCallback`](/maps/documentation/places/ios-sdk/reference/objc/Type-Definitions#/c:GMSPlacesClient.h@T@GMSPlaceResultCallback)\n to handle the response.\n\n- The response contains a\n [`GMSPlace`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace)\n instance containing details about the place. The values in the `types`\n property of the `GMSPlace` instance are now defined by\n [Table A](/maps/documentation/places/ios-sdk/place-types#table-a) and\n [Table B](/maps/documentation/places/ios-sdk/place-types#table-b).\n\n- The response `GMSPlace` instance contains the new `reviews`\n property of type [`GMSPlaceReview`](/maps/documentation/places/ios-sdk/refereference/objc/Classes/GMSPlaceReview).\n When your app displays information obtained from the `GMSPlace`\n instance, such as photos and reviews, the app must also display the required\n attributions.\n\n For more information, see the documentation on\n [attributions](/maps/documentation/places/ios-sdk/policies#other_attribution_requirements).\n- The response `GMSPlace` instance contains the following member functions:\n\n - [`isOpen`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace#-isopen)\n calculates whether a place is open at the given time.\n\n - [`isOpenAtDate`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace#-isopenatdate:)\n calculates whether a place is open on a given date.\n\n These functions are only available when you enable\n **Places SDK for iOS** . They are not available when you\n enable **Places SDK for iOS (New)** . For more information,\n see [Choose your SDK version](/maps/documentation/places/ios-sdk/choose-sdk).\n\nExample request\n---------------\n\nWith Place Details (New), you make a request and\npass all parameters in the `GMSFetchPlaceRequest` instance. This\nexample also uses a field mask so the response only includes the display name\nand website URL for the place: \n\n### Swift\n\n```swift\n// A hotel in Saigon with an attribution.\nlet placeID = \"ChIJV4k8_9UodTERU5KXbkYpSYs\"\n\n// Specify the place data types to return.\nlet fields = [GMSPlaceProperty.name, GMSPlaceProperty.website].map {$0.rawValue}\n\n// Create the GMSFetchPlaceRequest instance.\nlet fetchPlaceRequest = GMSFetchPlaceRequest(placeID: placeID, placeProperties: fields, sessionToken: nil)\n\nclient.fetchPlaceWithRequest(fetchPlaceRequest: fetchPlaceRequest, callback: {\n (place: GMSPlace?, error: Error?) in\n guard let place, error == nil else { return }\n print(\"Place found: \\(String(describing: place.name))\")\n})\n```\n\n### Objective-C\n\n```objective-c\n// A hotel in Saigon with an attribution.\nNSString *placeID = @\"ChIJV4k8_9UodTERU5KXbkYpSYs\";\n\n// Specify the place data types to return.\nNSArray\u003cNSString *\u003e *fields = @[GMSPlacePropertyName, GMSPlacePropertyWebsite];\n\n// Create the GMSFetchPlaceRequest instance.\nGMSFetchPlaceRequest *fetchPlaceRequest = [[GMSFetchPlaceRequest alloc] initWithPlaceID:placeID placeProperties: fields sessionToken:nil];\n\n[placesClient fetchPlaceWithRequest: fetchPlaceRequest callback: ^(GMSPlace *_Nullable place, NSError *_Nullable error) {\n if (error != nil) {\n NSLog(@\"An error occurred %@\", [error localizedDescription]);\n return;\n } else {\n NSLog(@\"Place Found: %@\", place.name);\n NSLog(@\"The place URL: %@\", place.website);\n }\n}];\n```"]]