O mascaramento de campo é obrigatório. É necessário especificar quais campos você quer que sejam retornados na resposta. Não há uma lista padrão de campos retornados. Se você omitir essa lista, os métodos vão retornar um erro.
A resposta contém uma instância GMSPlace com detalhes sobre o lugar. Os valores na propriedade types da instância GMSPlace agora são definidos pela Tabela A e pela Tabela B.
A instância de resposta GMSPlace contém a nova propriedade reviews do tipo GMSPlaceReview.
Quando o app mostra informações obtidas da instância GMSPlace, como fotos e avaliações, ele também precisa mostrar as atribuições necessárias.
Para mais informações, consulte a documentação sobre
atribuições.
A instância de resposta GMSPlace contém as seguintes funções de membro:
isOpen
calcula se um lugar está aberto no horário especificado.
isOpenAtDate
calcula se um lugar está aberto em uma determinada data.
Essas funções só estão disponíveis quando você ativa o SDK do Places para iOS. Eles não estão disponíveis quando você ativa o SDK do Places para iOS (novo). Para mais informações, consulte Escolher sua versão do SDK.
Exemplo de solicitação
Com o Place Details (novo), você faz uma solicitação e transmite todos os parâmetros na instância GMSFetchPlaceRequest. Este
exemplo também usa uma máscara de campo para que a resposta inclua apenas o nome de exibição
e o URL do site do lugar:
Swift
// 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,["Última atualização 2025-08-31 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```"]]