GMSAutocompletePrediction.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // GMSAutocompletePrediction.h
  3. // Google Places SDK for iOS
  4. //
  5. // Copyright 2016 Google LLC
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #import <Foundation/Foundation.h>
  11. NS_ASSUME_NONNULL_BEGIN
  12. #if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
  13. /**
  14. * Attribute name for match fragments in |GMSAutocompletePrediction| attributedFullText.
  15. *
  16. * @related GMSAutocompletePrediction
  17. */
  18. extern NSAttributedStringKey const kGMSAutocompleteMatchAttribute;
  19. #else
  20. /**
  21. * Attribute name for match fragments in |GMSAutocompletePrediction| attributedFullText.
  22. *
  23. * @related GMSAutocompletePrediction
  24. */
  25. extern NSString *const kGMSAutocompleteMatchAttribute;
  26. #endif
  27. /**
  28. * This class represents a prediction of a full query based on a partially typed string.
  29. */
  30. @interface GMSAutocompletePrediction : NSObject
  31. /**
  32. * The full description of the prediction as a NSAttributedString. E.g., "Sydney Opera House,
  33. * Sydney, New South Wales, Australia".
  34. *
  35. * Every text range that matches the user input has a |kGMSAutocompleteMatchAttribute|. For
  36. * example, you can make every match bold using enumerateAttribute:
  37. * <pre>
  38. * UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
  39. * UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
  40. *
  41. * NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy];
  42. * [bolded enumerateAttribute:kGMSAutocompleteMatchAttribute
  43. * inRange:NSMakeRange(0, bolded.length)
  44. * options:0
  45. * usingBlock:^(id value, NSRange range, BOOL *stop) {
  46. * UIFont *font = (value == nil) ? regularFont : boldFont;
  47. * [bolded addAttribute:NSFontAttributeName value:font range:range];
  48. * }];
  49. *
  50. * label.attributedText = bolded;
  51. * </pre>
  52. */
  53. @property(nonatomic, copy, readonly) NSAttributedString *attributedFullText;
  54. /**
  55. * The main text of a prediction as a NSAttributedString, usually the name of the place.
  56. * E.g. "Sydney Opera House".
  57. *
  58. * Text ranges that match user input are have a |kGMSAutocompleteMatchAttribute|,
  59. * like |attributedFullText|.
  60. */
  61. @property(nonatomic, copy, readonly) NSAttributedString *attributedPrimaryText;
  62. /**
  63. * The secondary text of a prediction as a NSAttributedString, usually the location of the place.
  64. * E.g. "Sydney, New South Wales, Australia".
  65. *
  66. * Text ranges that match user input are have a |kGMSAutocompleteMatchAttribute|, like
  67. * |attributedFullText|.
  68. *
  69. * May be nil.
  70. */
  71. @property(nonatomic, copy, readonly, nullable) NSAttributedString *attributedSecondaryText;
  72. /**
  73. * A property representing the place ID of the prediction, suitable for use in a place details
  74. * request.
  75. */
  76. @property(nonatomic, copy, readonly) NSString *placeID;
  77. /**
  78. * The types of this autocomplete result. Types are NSStrings, valid values are any types
  79. * documented at <https://developers.google.com/places/ios-sdk/supported_types>.
  80. */
  81. @property(nonatomic, copy, readonly) NSArray<NSString *> *types;
  82. /**
  83. * The straight line distance in meters between the origin and this prediction if a valid origin is
  84. * specified in the |GMSAutocompleteFilter| of the request.
  85. */
  86. @property(nonatomic, readonly, nullable) NSNumber *distanceMeters;
  87. /**
  88. * Initializer is not available.
  89. */
  90. - (instancetype)init NS_UNAVAILABLE;
  91. @end
  92. NS_ASSUME_NONNULL_END