장소 세부정보 (신규)

플랫폼 선택: Android iOS JavaScript 웹 서비스

iOS용 Places SDK (신규)는 앱에 풍부한 정보를 제공합니다. 장소에 대한 정보와 함께 해당 장소의 이름 및 주소, 지리적 위치, 위도/경도 좌표로 지정된 위치, 장소의 유형 (예: 나이트클럽, 애완동물 용품점, 박물관 등입니다. 이러한 정보에 액세스하려면 장소 ID를 사용할 수 있습니다. 장소 ID는 는 장소를 식별합니다.

장소 세부정보 가져오기

GMSPlace 드림 클래스에는 표시된 모든 데이터 필드를 비롯하여 특정 장소에 대한 정보가 포함됩니다. 장소 데이터 필드 (신규). 받기 GMSPlace 드림 객체를 GMSPlacesClient fetchPlaceWithRequest:님, GMSFetchPlaceRequest 객체와 다음 유형의 콜백 메서드 GMSPlaceResultCallback.

GMSFetchPlaceRequest 객체는 다음을 지정합니다.

  • (필수) 장소 ID(Google 지역 정보에 등록된 장소의 고유 식별자) Google 지도에 바로 표시할 수 있습니다.
  • (필수) GMSPlace 객체에서 반환할 필드 목록으로, 필드 마스크, 즉 GMSPlaceProperty 필드 목록에 필드를 하나 이상 지정하지 않거나 필드 목록에 없으면 호출이 오류를 반환합니다.
  • (선택사항) 응답 형식을 지정하는 데 사용되는 지역 코드입니다.
  • (선택사항) 자동 완성 (신규) 세션을 종료하는 데 사용되는 세션 토큰입니다.

Place Details 요청

이 예에서는 ID별로 장소를 가져오고 다음 매개변수를 전달합니다.

  • ChIJV4k8_9UodTERU5KXbkYpSYs의 장소 ID입니다.
  • 장소 이름과 웹사이트 URL을 반환하도록 지정하는 필드 목록입니다.
  • GMSPlaceResultCallback 결과를 처리합니다

API는 지정된 콜백 메서드를 호출하고 GMSPlace 드림 객체를 지정합니다. 장소를 찾을 수 없는 경우 장소 객체는 nil입니다.

Swift

// A hotel in Saigon with an attribution.
let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"

// Specify the place data types to return.
let myProperties = [GMSPlaceProperty.name, GMSPlaceProperty.website].map {$0.rawValue}

// Create the GMSFetchPlaceRequest object.
let fetchPlaceRequest = GMSFetchPlaceRequest(placeID: placeID, placeProperties: myProperties, sessionToken: nil)

client.fetchPlace(with: fetchPlaceRequest, callback: {
  (place: GMSPlace?, error: Error?) in
  guard let place, error == nil else { 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 *> *myProperties = @[GMSPlacePropertyName, GMSPlacePropertyWebsite];

// Create the GMSFetchPlaceRequest object.
GMSFetchPlaceRequest *fetchPlaceRequest = [[GMSFetchPlaceRequest alloc] initWithPlaceID:placeID placeProperties: myProperties sessionToken:nil];

[placesClient fetchPlaceWithRequest: fetchPlaceRequest callback: ^(GMSPlace *_Nullable place, NSError *_Nullable error) {
    if (error != nil) {
      NSLog(@"An error occurred %@", [error localizedDescription]);
      return;
    } else {
    NSLog(@"Place Found: %@", place.name);
    NSLog(@"The place URL: %@", place.website);
  }
}];

iOS용 Places Swift SDK (미리보기)

// A hotel in Saigon with an attribution.
let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"
let fetchPlaceRequest = FetchPlaceRequest(
  placeID: placeID,
  placeProperties: [.name, .website]
)
switch await placesClient.fetchPlace(with: fetchPlaceRequest) {
case .success(let place):
  // Handle place
case .failure(let placesError):
  // Handle error
}

장소 세부정보 응답

Place Details는 장소에 대한 세부정보가 포함된 GMSPlace 객체입니다. 필드 목록에 지정된 필드만 GMSPlace 객체에 채워집니다.

영업 개시 상태 가져오기

GMSPlacesClient 객체에는 호출에 지정된 시간을 기준으로 장소가 현재 영업 중인지 나타내는 응답을 반환하는 isOpenWithRequest (Swift의 경우 isOpenRequest, GooglePlacesSwift의 경우 isPlaceOpenRequest)라는 멤버 함수가 포함되어 있습니다.

이 메서드는 다음을 포함하는 GMSPlaceIsOpenWithRequest 유형의 단일 인수를 사용합니다.

  • GMSPlace 객체 또는 장소 ID를 지정하는 문자열. 필수 필드를 사용하여 Place 객체를 만드는 방법에 관한 자세한 내용은 장소 세부정보를 참고하세요.
  • 확인할 시간을 지정하는 선택적 NSDate (Obj-C) 또는 Date (Swift) 객체입니다. 시간을 지정하지 않으면 기본값은 지금입니다.
  • 응답을 처리하는 GMSPlaceOpenStatusResponseCallback 메서드
  • &gt;
를 통해 개인정보처리방침을 정의할 수 있습니다.

GMSPlaceIsOpenWithRequest 메서드를 사용하려면 GMSPlace 객체에 다음 필드를 설정해야 합니다.

  • GMSPlacePropertyUTCOffsetMinutes
  • GMSPlacePropertyBusinessStatus
  • GMSPlacePropertyOpeningHours
  • GMSPlacePropertyCurrentOpeningHours
  • GMSPlacePropertySecondaryOpeningHours

이러한 필드가 장소 객체에 제공되지 않거나 장소 ID를 전달하는 경우 메서드는 GMSPlacesClient GMSFetchPlaceRequest:를 사용하여 필드를 가져옵니다.

응답 isOpenWithRequest

isOpenWithRequest는 비즈니스가 영업 중인지, 폐업했는지 또는 상태를 알 수 없는지를 나타내는 불리언 값 status이 포함된 GMSPlaceIsOpenResponse 객체를 반환합니다.

언어 열려 있는 경우 값 닫힌 경우의 값 상태를 알 수 없는 경우 값
Swift .open .closed .unknown
Objective-C GMSPlaceOpenStatusOpen GMSPlaceOpenStatusClosed GMSPlaceOpenStatusUnknown
GooglePlacesSwift (미리보기) true false nil

isOpenWithRequest 결제

  • GMSPlacePropertyUTCOffsetMinutesGMSPlacePropertyBusinessStatus 필드는 Basic Data SKU에 따라 요금이 청구됩니다. 남은 영업시간은 Place Details (Advanced) SKU에 따라 요금이 청구됩니다.
  • GMSPlace 객체에 이전 요청의 해당 필드가 이미 포함되어 있으면 다시 청구되지 않습니다.

예: GMSPlaceIsOpenWithRequest 요청 실행

다음 예는 기존 GMSPlace 객체 내에서 GMSPlaceIsOpenWithRequest를 초기화하는 방법을 보여줍니다.

Swift

    let isOpenRequest = GMSPlaceIsOpenRequest(place: place, date: nil)
      GMSPlacesClient.shared().isOpen(with: isOpenRequest) { response, error in
        if let error = error {
          // Handle Error
        }
        switch response.status {
          case .open:
            // Handle open
          case .closed:
            // Handle closed
          case .unknown:
            // Handle unknown
        }
      }
        

Objective-C

          GMSPlaceIsOpenRequest *isOpenRequest = [[GMSPlaceIsOpenRequest alloc] initWithPlace:place date:nil];
  
          [[GMSPlacesClient sharedClient] isOpenWithRequest:isOpenRequest callback:^(GMSPlaceIsOpenResponse response, NSError *_Nullable error) {
            if (error) {
              // Handle error
            }
  
            switch (response.status) {
              case GMSPlaceOpenStatusOpen:
                // Handle open
              case GMSPlaceOpenStatusClosed:
                // Handle closed
              case GMSPlaceOpenStatusUnknown:
                // Handle unknown
            }
          }];
          

GooglePlacesSwift

          let isOpenRequest = IsPlaceOpenRequest(place: place)
          switch await placesClient.isPlaceOpen(with: isOpenRequest) {
            case .success(let isOpenResponse):
              switch isOpenResponse.status {
                case true:
                  // Handle open
                case false:
                  // Handle closed
                case nil:
                  // Handle unknown
            case .failure(let placesError):
              // Handle error
          }
          

필수 매개변수

GMSFetchPlaceRequest 객체를 사용하여 필수 매개변수를 지정합니다.

장소 ID

iOS용 Places SDK에서 사용되는 장소 ID는 Places API, Android용 Places SDK에서 사용되는 것과 동일한 식별자 사용할 수 있습니다 각 장소 ID는 한 장소만 참조할 수 있지만 단일 장소가 여러 장소를 참조할 수 있습니다. 한 개 이상의 장소 ID가 있어야 합니다.

장소에 따라 새 장소 ID가 부여될 수도 있습니다. 예를 들어, 사업체를 새 위치로 이전하는 경우에 이러한 상황이 발생할 수 있습니다.

장소 ID를 지정하여 장소를 요청하면 응답에서 항상 동일한 장소를 받게 됩니다 (장소가 있음). 그러나 응답에 이전에 사용한 것과 다르게 표시됩니다.

필드 목록

장소 세부정보를 요청할 때 데이터를 지정해야 합니다. 장소의 GMSPlace 객체에 필드 마스크로 반환됩니다. 필드 마스크 정의 값 배열을 전달하여 GMSPlaceProperty GMSFetchPlaceRequest 객체에 추가합니다. 필드 마스킹은 불필요한 데이터를 요청하지 않도록 하는 좋은 설계 방법입니다. 불필요한 처리에 드는 시간과 요금 청구를 방지할 수 있습니다.

다음 필드 중 하나 이상을 지정합니다.

  • 다음 필드는 Place Details (ID Only) SKU를 트리거합니다.

    GMSPlacePropertyPlaceID, GMSPlacePropertyName, GMSPlacePropertyPhotos

  • 다음 필드는 Place Details (Location Only) SKU를 트리거합니다.

    GMSPlacePropertyAddressComponents, GMSPlacePropertyFormattedAddress, GMSPlacePropertyCoordinate, GMSPlacePropertyPlusCode님, GMSPlacePropertyTypes, GMSPlacePropertyViewport

  • 다음 필드는 Place Details (Basic) SKU를 트리거합니다.

    GMSPlacePropertyBusinessStatus, GMSPlacePropertyIconBackgroundColor, GMSPlacePropertyIconImageURL, GMSPlacePropertyUTCOffsetMinutes님, GMSPlacePropertyWheelchairAccessibleEntrance

  • 다음 필드는 Place Details (Advanced) SKU를 트리거합니다.

    GMSPlacePropertyCurrentOpeningHours, GMSPlacePropertySecondaryOpeningHours, GMSPlacePropertyPhoneNumber, GMSPlacePropertyPriceLevel님, GMSPlacePropertyRating, GMSPlacePropertyOpeningHours, GMSPlacePropertyUserRatingsTotal, GMSPlacePropertyWebsite

  • 다음 필드는 Place Details (Preferred) SKU를 트리거합니다.

    GMSPlacePropertyCurbsidePickup, GMSPlacePropertyDelivery, GMSPlacePropertyDineIn, GMSPlacePropertyEditorialSummary님, GMSPlacePropertyReservable, GMSPlacePropertyReviews, GMSPlacePropertyServesBeer, GMSPlacePropertyServesBreakfast, GMSPlacePropertyServesBrunch, GMSPlacePropertyServesDinner, GMSPlacePropertyServesLunch, GMSPlacePropertyServesVegetarianFood, GMSPlacePropertyServesWine, GMSPlacePropertyTakeout

다음 예는 두 개의 필드 값 를 사용하여 요청에서 반환된 GMSPlace 객체에 nameplaceID 필드:

Swift

// Specify the place data types to return.
let fields: [GMSPlaceProperty] = [.placeID, .name]
  

Objective-C

// Specify the place data types to return.
NSArray<GMSPlaceProperty *> *fields = @[GMSPlacePropertyPlaceID, GMSPlacePropertyName];
  

iOS용 Places Swift SDK (미리보기)

// Specify the place data types to return.
let fields: [PlaceProperty] = [.placeID, .displayName]
    

선택적 매개변수

GMSFetchPlaceRequest 객체를 사용하여 선택적 매개변수를 지정합니다.

regionCode

응답 형식을 지정하는 데 사용되는 지역 코드로, <ph type="x-smartling-placeholder"></ph> 2자리 CLDR 코드 값을 제공합니다. 이 매개변수는 편향 효과가 발생할 수도 있습니다. 도움이 될 수 있습니다 기본값은 없습니다.

응답의 주소 입력란 국가 이름이 국가 코드는 주소에서 생략됩니다.

대부분의 CLDR 코드는 ISO 3166-1 코드와 동일하지만 몇 가지 주목할 만한 예외가 있습니다 예를 들어 영국의 ccTLD는 'uk' (.co.uk), ISO 3166-1 코드는 'gb'입니다. (기술적으로 '영국 및 북아일랜드'의 법인 소유입니다. 매개변수는 관련 법률에 따라 결과에 영향을 미칠 수 있습니다.

sessionToken

세션 토큰은 자동 완성을 추적하는 사용자 생성 문자열입니다. (신규) 통화를 '세션'으로 집계 자동 완성 (신규)은 세션 토큰을 사용하여 사용자 자동 완성 검색의 쿼리 및 장소 선택 단계를 개별 세션으로 그룹화 사용할 수 없습니다. 세션 토큰이 장소 세부정보로 전달됨 (신규) 자동 완성 (신규) 호출 이후의 모든 호출 자세한 내용은 세션 토큰.

앱에 특성 표시

앱이 GMSPlacesClient님, 앱은 필수 저작자 표시도 표시해야 합니다.

예를 들어 GMSPlacesClient 객체의 reviews 속성입니다. 최대 다섯 개의 GMSPlaceReview 객체입니다. 각 GMSPlaceReview 객체에는 속성 및 작성자 속성이 포함될 수 있습니다. 앱에서 리뷰를 표시하는 경우 저작자 표시나 작성자도 표시해야 합니다. 저작자 표시입니다.

자세한 내용은 기여 분석이 있습니다.