GMSAutocompletePrediction 類別參考資料

GMSAutocompletePrediction 類別參考資料

總覽

此類別代表根據部分輸入的字串來預測完整查詢。

房源

NSAttributedString *attributedFullText
 預測結果 (格式為 NSAttributedString) 的完整說明。
NSAttributedString *attributedPrimaryText
 預測結果做為 NSAttributedString 的主要文字,通常是地點的名稱。
NSAttributedString *attributedSecondaryText
 預測結果做為 NSAttributedString 的次要文字,通常是地點位置。
NSString *placeID
 代表預測結果地點 ID 的屬性,適用於 Place Details 要求。
NSArray<NSString * >。類型
 這個自動完成結果的類型。
NSNumber *distanceMeters
 在要求的 GMSAutocompleteFilter 中指定有效起點時,起點和這項預測之間的直線距離 (以公尺為單位)。

(請注意,這些並非成員函式)。

NSString *constkGMSAutocompleteMatchAttribute
 GMSAutocompletePrediction AttributionFullText 中相符片段的屬性名稱。

- (NSString* const) kGMSAutocompleteMatchAttribute [related]

GMSAutocompletePrediction AttributionFullText 中相符片段的屬性名稱。


屬性說明文件

- (NSAttributedString*) attributedFullText [read, copy]

預測結果 (格式為 NSAttributedString) 的完整說明。

例如:「雪梨歌劇院 Sydney, New South Wales, Australia」。

符合使用者輸入內容的每個文字範圍都有 kGMSAutocompleteMatchAttribute。舉例來說,您可以使用 enumerateAttribute 將每個相符項目設為粗體:

   UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
   UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
   NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy];
   [bolded enumerateAttribute:kGMSAutocompleteMatchAttribute
                      inRange:NSMakeRange(0, bolded.length)
                      options:0
                   usingBlock:^(id value, NSRange range, BOOL *stop) {
                     UIFont *font = (value == nil) ? regularFont : boldFont;
                     [bolded addAttribute:NSFontAttributeName value:font range:range];
                   }];
   label.attributedText = bolded;
 
- (NSAttributedString*) attributedPrimaryText [read, copy]

預測結果做為 NSAttributedString 的主要文字,通常是地點的名稱。

例如:「雪梨歌劇院」。

符合使用者輸入內容的文字範圍會包含 kGMSAutocompleteMatchAttribute,例如 attributedFullText

- (NSAttributedString*) attributedSecondaryText [read, copy]

預測結果做為 NSAttributedString 的次要文字,通常是地點位置。

例如:「澳洲新南威爾斯州雪梨」。

符合使用者輸入內容的文字範圍會包含 kGMSAutocompleteMatchAttribute,例如 attributedFullText

可能為空值。

- (NSString*) <地點 ID>placeID [read, copy]

代表預測結果地點 ID 的屬性,適用於 Place Details 要求。

- (NSArray<NSString *>*) 類型 [read, copy]

這個自動完成結果的類型。

類型為 NSString,有效值為 <https://developers.google.com/places/ios-sdk/supported_types> 列出的任何類型。

- (NSNumber*) distanceMeters [read, assign]

在要求的 GMSAutocompleteFilter 中指定有效起點時,起點和這項預測之間的直線距離 (以公尺為單位)。